Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blazor Component Embedded in Razor Page #9834

Closed
CarrotSolutions opened this issue Apr 29, 2019 · 7 comments

Comments

Projects
6 participants
@CarrotSolutions
Copy link

commented Apr 29, 2019

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> 

@CarrotSolutions

This comment has been minimized.

Copy link
Author

commented Apr 30, 2019

I can replicate this scenario in any standard MVC or Razor Page default template. Link to a page with a Blazor component and all of the other page links will no longer function. You can even replicate the same situation using the boilerplate template app for a Blazor Server Side app and linking to any mvc view or razor page. All links no longer work. This has to be a Startup issue. Removing
endpoints.MapBlazorHub(); will allow the links to work again but obviously that breaks the Blazor component.

@CarrotSolutions

This comment has been minimized.

Copy link
Author

commented Apr 30, 2019

@mkArtakMSFT mkArtakMSFT added this to To do in Blazor May 1, 2019

@stavroskasidis

This comment has been minimized.

Copy link

commented May 1, 2019

I can also replicate this. I guess it has something to do with the client-side router, probably hijacking the url changes and trying to resolve them to components.

@CarrotSolutions

This comment has been minimized.

Copy link
Author

commented May 1, 2019

Exactly, The capability of being able to use Blazor components inside of existing Razor or MVC apps is where this tech will gain traction in the beginning . Note, I also tried mapping the razor pages inside Startup, verifying all pages has unique routes, etc. Nothing works.

@chrdlx

This comment has been minimized.

Copy link

commented May 7, 2019

I also replicated this using razor pages.

@pranavkm pranavkm added bug cost: S Working and removed investigate labels May 8, 2019

pranavkm added a commit that referenced this issue May 8, 2019

pranavkm added a commit that referenced this issue May 8, 2019

pranavkm added a commit that referenced this issue May 8, 2019

pranavkm added a commit that referenced this issue May 8, 2019

pranavkm added a commit that referenced this issue May 8, 2019

pranavkm added a commit that referenced this issue May 8, 2019

pranavkm added a commit that referenced this issue May 8, 2019

@rynowak rynowak moved this from To do to In progress in Blazor May 10, 2019

pranavkm added a commit that referenced this issue May 16, 2019

pranavkm added a commit that referenced this issue May 16, 2019

pranavkm added a commit that referenced this issue May 17, 2019

Blazor automation moved this from In progress to Done May 17, 2019

@pranavkm pranavkm added Done and removed Working labels May 17, 2019

pranavkm added a commit that referenced this issue May 17, 2019

Defer link interception until Router is initialized (#10062)
* Defer link interception until Router is initialized

Fixes #9834
@chrdlx

This comment has been minimized.

Copy link

commented May 18, 2019

Just curious, when an issue like this is CLOSED, does it mean that if I download the latest master, should it be fixed? Thanks

@danroth27

This comment has been minimized.

Copy link
Member

commented May 30, 2019

@chrdlx Yes, but potentially with some latency as it takes some time for all the ASP.NET Core bits to make their way into the .NET Core SDK builds: https://github.com/aspnet/AspNetCore/blob/master/docs/DailyBuilds.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.