Can I use URL Rewrite with web.config on ASP.NET Core Projects?

I’m getting conflicting information so hopefully someone can point me in the right direction.

I have a couple of APIs hosted in Azure and want to redirect the URLs. I’ve tried to use the web.config in the app service to rewrite the URL but it doesn’t work, after some research, there’s some evidence to suggest it does not work and the Middleware should be used instead, whilst other information suggests the Middleware is best practice.

My aim is to implement the middleware at some point but want to know if I can use web.config as a stop gap whilst I work on that.

Can anyone give me a definitive answer? Preferably with some back up info if possible?

Thanks

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Yes, you can, with a caveat. Extracted from this document:

The table indicates native IIS modules that are functional with ASP.NET Core apps and the ASP.NET Core Module.

Module             Functional with ASP.NET Core apps    ASP.NET Core Option
----------------------------------------------------------------------------
URL Rewriting†     Yes                                  URL Rewriting Middleware

The caveat is the :

The URL Rewrite Module’s isFile and isDirectory match types don’t work with ASP.NET Core apps due to the changes in directory structure.


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x