Reputation: 1677
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
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:
TEST:
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