-
Notifications
You must be signed in to change notification settings - Fork 58
Issue: URL Rewrite using web.config is broken in RC2 #192
Comments
I'm going to ping @ciel on Slack, who may have a solution for this. |
I'll take a look at this when I get home this evening, sure. I'm using
|
I'm not at a computer right now, but looking at your sample have you tried using "^(.*)$" as the match url? And of course, you can confirm that you've got html5mode active? |
I haven't tried the regex "^(.*)$". Any links to your examples would be great! |
@anwalkers Were you able to verify the regex suggested by @ciel? |
@muratg I have not. I am on a deadline and have turned HTML5 routing off temporarily. Will tackle this when I get to the Azure WebApp deployment step. Hoping @ciel will have a link to an example along the way. That said, any progress on getting IIS Express from VS 2015 to pay attention to URL rewriting in the web.config? |
I tried the following code in my Startup.cs to do middleware URL rewrite. It works fine for the base URL, but does not support deep links into an AngularJS 1.x application with HTML5 routing enabled. It does work with HTML5 routing disabled. Works: Does not work: From Startup.cs:
Just for clarity, here is a snippet for enabling HTML5 routing in angular 1.x application. It removes the
Reference: https://docs.angularjs.org/guide/$location#! |
I have published a simple sample app to this repository. DELETED THIS REPO: https://github.com/anwalkers/AngularUrlRewriteAspNetCore1 This site is a vanilla ASP.Net Core 1 RC2 project using one MVC route to an index.cshtml as the root page for the site. It does not have the mapWhen function or static html in the wwwroot directory. It is checked in a broken state. You can switch it back to non-HTML5 mode by editing the site.js and a bit of markup. It also does not have mapWhen in the Startup.cs, wasn't sure how to mix the MVC routing and the mapWhen... It does have the rewrite rules in the web.config. |
I was able to repro this using just the UrlRewrite samples here: I see two issues:
Assigning to @pan-wang to debug. |
Has anyone found a work around? |
Unfortunately I haven't
|
I did find one where you can change |
Looking at it now |
FYI... Found this project with some middleware to solve the url rewrite problem. Something like this would make a nice addition to ASP.Net Core 1. https://github.com/BrainCrumbz/AWATTS/tree/master/src/WebPackAngular2TypeScript/Routing |
this is a bug in aspnetcore module. The fix will be included for next release. |
@pan-wang can you provide a brief explanation please? |
@anwalkers I'm trying to see if I can get that middleware implemented into my project as a workaround but appears to be for RC1. Did you try it with an RC2 project? @pan-wang Don't suppose you know when this release is expected to drop? |
I was able to use this as a quick workaround. routes.MapRoute("spa-routes", "{*anything}", new { controller = "Home", action = "Index" }); |
@WhittenMike807 I think this is working for me (have run into the next hurdle while upgrading to RC2). Are there any known pitfalls of taking this approach? |
I haven't encountered any issue so far. Seems like a "ok" fix for now |
FYI, this also blows up and prevents debugging from starting. (works fine in production)
|
@Tratcher Why is this closed? Has it been updated/fixed? |
Yes, this has been fixed for the upcoming release. |
@Tratcher Just so I can plan. You have a rough idea on when the next release will be by chance? |
@Tratcher My URL rewriting is still broken with the RTM release. Wasn't this intended to be fixed? |
@twilliamsgsnetx yes this was fixed in the 1.0 version of AspNetCoreModule. Have you've installed the new tooling? |
@Tratcher I have uninstalled all my previous .NET Core stuff and installed all the new versions, including visual studio tooling. Could IIS Express be utilizing an older version still somehow? How do I validate my version? I haven't changed anything in my URL rewriting logic from RC1 either, I don't know if this fix requires any slight modifications. |
Look in (MySolution).vs\config\applicationhost.config and find |
Yes. Mine is set that way, and my file is the version you specified. For clarification, my project's web.config is as follows
And my wwwroot config that has the url rewriting logic is as follows:
This was all working handily in RC1 with Angular 2. |
@ZestyBread can you try this? |
The web.config file doesn't exist in wwwroot anymore. Try combining the two together like:
|
@ZestyBread Consolidating to my web.config in the main project as you suggested, my entire app breaks. The client files aren't served properly and angular simply doesn't load. The rewrite section is specifically what seems to be causing it. I comment that out and everything is fine, except the inability to refresh the site on an angular router URL properly. I hope I'm not the only one experiencing this issue.
|
Ah, I know what's wrong here. We moved web.config and the app base dir, so rules with file constraints like Workaround: for IIS you can move the web.config back to the wwwroot dir. #164 Real solution: @ZestyBread is writing a url-rewrite middleware so we can move this directly into Asp.Net. |
Closing this one. aspnet/BasicMiddleware#43 is tracking the middleware work. |
I have tried moving the web.config to and fro and cannot get the URL rewrite to work in IIS Express from Visual Studio 2015. If there was middleware to perform what is spelled out in the web.config snippet I could punt on the web.config and selfhost. Maybe someone can point me in that direction to solve our problem.
We need to use Angular 1.x HTML 5 routing in our application and this is how we had solved it in RC1 but it doesn't work in RC2. Others are having trouble as well: http://stackoverflow.com/questions/37304113/url-rewriting-in-asp-net-core-rc2#
The text was updated successfully, but these errors were encountered: