mattfullerdev
mattfullerdev

Reputation: 129

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

Upvotes: 3

Views: 2120

Answers (1)

stuartd
stuartd

Reputation: 73303

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.

Upvotes: 5

Related Questions