Closed mkArtakMSFT closed 6 years ago
Thanks for contacting us, @lonix1. Please provide us with a minimalistic repro project so we can investigate the issue.
From @kichalla on August 10, 2018 18:30
cc @jkotalik
From @jkotalik on August 10, 2018 18:32
Seems like a bug, will look into it in the 2.2 timeframe.
@jkotalik, should this be moved to a different repo?
From @jkotalik on August 10, 2018 23:16
Oops: just BasicMiddleware: https://github.com/aspnet/BasicMiddleware
From @gsdnano on August 11, 2018 3:28
This can be reproduced by taking the example at https://docs.microsoft.com/en-us/aspnet/core/fundamentals/url-rewriting?view=aspnetcore-2.1&tabs=aspnetcore2x and commenting out the app.Run command at the end of the Configure function. The url rewrite example will then 404 no matter the replacement url. This is using core 2.1 and Microsoft.AspNetCore.Rewrite 2.1.1.
From @lonix1 on August 11, 2018 6:0
Once this bug is resolved, please also give us some guidance (or better yet, update the docs) about the implications of putting this before/after/between app.UseStaticFiles()
and app.UseMvc()
, or whether it should be at the beginning/end of Configure()
i.e. the beginning/end of the pipeline.
@muratg FYI
So I followed the docs and did this in Startup.cs at the end of Configure() (after app.UseMvc(), I hope that's correct?):
Rewrite must come early in the pipeline, not at the end. In your case it needs to come before UseStaticFiles.
@lonix1 I assume this solved your issue. Closing. You may reopen if you are still having issues.
From @lonix1 on August 10, 2018 16:10
ASP.NET Core 2.1 (2.1.302)
I want to rewrite
/favicon.ico
to/images/favico.ico
.So I followed the docs and did this in
Startup.cs
at the end ofConfigure()
(afterapp.UseMvc()
, I hope that's correct?):But that gave me a 404.
So I thought maybe I need to use a dummy regex:
And that also gave me a 404.
This was confirmed by other people on SO, so it's either a bug, or the documentation is wrong (in which case please correct me).
Copied from original issue: aspnet/Mvc#8254