Skip to content

Blazor Component Embedded in Razor Page #9834

@CarrotSolutions

Description

@CarrotSolutions

Repo: https://github.com/CarrotSolutions/WebApplication1.git

Please Help! We created a basic template razor page app. We added Blazor components. We have no problem getting this to work via replicating the steps in the 04/16 Blazor Update video or using the Blazor documentation. However, once we add the Blazor component to a Razor page, all of our asp-page links no longer work. The url changes in the address bar, but we remain on the same page. The startup file is as follows:

public void ConfigureServices(IServiceCollection services)
        {
            services.Configure<CookiePolicyOptions>(options =>
            {
                options.CheckConsentNeeded = context => true;
            });


            services.AddRazorPages()
                .AddNewtonsoftJson();

            services.AddServerSideBlazor();
        }

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseCookiePolicy();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
                endpoints.MapBlazorHub();
            });
        }

Page with working Component and broken link


<a asp-page="./Index">Home</a>

<br /> 

<div id="Counter"> 
    @(await Html.RenderComponentAsync<Counter>()) 
    <script src="~/_framework/blazor.server.js">
</script> 

Metadata

Metadata

Assignees

Labels

DoneThis issue has been fixedarea-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions