You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
Asp.net Core 2 Razor Pages MapSpaFallback suggestion #1354
MapSpaFallback works well for MVC routes but does not exist for the new Razor Pages.
If SpaRouteConstraint were public instead of internal with a little work developers can add the constraint to Razor pages:
//Starup.cs ConfigureServices//thank you Scott Hanselman https://www.hanselman.com/blog/AddingACustomInlineRouteConstraintInASPNETCore10.aspxservices.Configure<RouteOptions>(options =>options.ConstraintMap.Add("spaRoute",typeof(SpaRouteConstraint)));services.AddMvc().AddRazorPagesOptions(options =>{options.Conventions.AddPageRoute("/Index","{*catchAll:spaRoute(catchAll)}");});
Would be even better if JavaScriptServices somehow added SpaRouteConstraint to the ConstraintMap.
For now I'll just copy the SpaRouteConstraint class.
Thanks,
Philip
Thanks for the suggestion. In the next update, we're providing an alternative to MapSpaFallbackRoute that isn't coupled to the concept of MVC actions. It looks like this:
app.UseSpa("root-directory-goes-here", () => { /* config goes here */ });
This is generic middleware that you can use either with MVC or Razor projects. Hopefully that will cover your requirements even more cleanly.
Reacted by Richard Simpson, Chris Quick, Pedro Osternack Correa, send0xx, Vlad Isambaiev, Roger Far and Preston Alvarado
Thanks @SteveSandersonMS - turns out it was a completely unrelated problem to spaservices! It was an SSL error. @jfborie I'm probably not best placed to help as I'm fairly new with the framework myself; however if you post your issue up separately and reference it I'm happy to take a look and see if i have any suggestions. Make sure you tell us what the error is with any code you can share
Activity
buvinghausen commentedon Oct 25, 2017
I have just been using a regex to exclude the api routes.....
SteveSandersonMS commentedon Oct 26, 2017
Thanks for the suggestion. In the next update, we're providing an alternative to
MapSpaFallbackRoutethat isn't coupled to the concept of MVC actions. It looks like this:This is generic middleware that you can use either with MVC or Razor projects. Hopefully that will cover your requirements even more cleanly.
RichiCoder1 commentedon Oct 27, 2017
@SteveSandersonMS That'd be awesome. On at least two of my projects, there's just a thin layer of razor over an index.html (generated by webpack).
StefanKern commentedon Feb 17, 2018
@buvinghausen thank you for your solution. I took me a long time to understand it but it works now.
@SteveSanderson: when is this app.UseSpa avalible. With the newset version of .Net Core I don't have it yet :(
jjgriff93 commentedon Oct 13, 2018
@SteveSandersonMS also facing this issue still - is this an update we can expect soon?
SteveSandersonMS commentedon Oct 15, 2018
@jjgriff93 We shipped
UseSpain ASP.NET Core 2.1.jjgriff93 commentedon Oct 16, 2018
Thanks @SteveSandersonMS - turns out it was a completely unrelated problem to spaservices! It was an SSL error. @jfborie I'm probably not best placed to help as I'm fairly new with the framework myself; however if you post your issue up separately and reference it I'm happy to take a look and see if i have any suggestions. Make sure you tell us what the error is with any code you can share