Simon Ordo
Simon Ordo

Reputation: 1677

ASP.NET Core 2.0 URL rewriting in Azure

I have a client that's converting from a PHP system to a .NET system. One requirement is that certain legacy system URLs ending in ".php" are still accessible in the new .NET environment.

Essentially I need to map arbitrary string paths to specific Controllers/Actions.

Can anyone tell me what the recommended and most performant approach is in ASP.NET Core 2.0 to handle this scenario? Custom middleware? Introduce a Web.Config? Action attributes in the controller?

Are there any "gotchas" I should be on the lookout for?

The site is hosted in Azure, if that makes a difference.

Thanks in advance!

Upvotes: 1

Views: 970

Answers (1)

Bruce Chen
Bruce Chen

Reputation: 18465

Can anyone tell me what the recommended and most performant approach is in ASP.NET Core 2.0 to handle this scenario? Custom middleware? Introduce a Web.Config? Action attributes in the controller?

I assume that you could leverage URL Rewrite and read the related tutorials. I just checked it and added the URL rewrite rule under my azure web app via the Azure App Service Editor as follows:

enter image description here

TEST:

enter image description here

Additionally, you could also write the URL rewrite rules in your code, details you could follow URL Rewriting Middleware in ASP.NET Core.

Upvotes: 1

Related Questions