Azure 中的 ASP.NET Core 2.0 URL 重写

标签 asp.net asp.net-mvc azure asp.net-core azure-web-app-service

我有一个客户端正在从 PHP 系统转换为 .NET 系统。其中一项要求是某些以“.php”结尾的旧系统 URL 在新的 .NET 环境中仍然可以访问。

本质上,我需要将任意字符串路径映射到特定的 Controller /操作。

谁能告诉我 ASP.NET Core 2.0 中推荐的、性能最高的方法是什么来处理这种情况?自定义中间件?引入一个Web.Config? Controller 中的操作属性?

有什么我应该注意的“陷阱”吗?

该网站托管在 Azure 中(如果这有区别的话)。

提前致谢!

最佳答案

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?

我认为您可以利用 URL Rewrite并阅读相关教程。我刚刚检查了它并通过 Azure App Service Editor 在我的 azure web 应用程序下添加了 URL 重写规则如下:

enter image description here

测试:

enter image description here

另外,您还可以在代码中编写URL重写规则,具体可以引用URL Rewriting Middleware in ASP.NET Core .

关于Azure 中的 ASP.NET Core 2.0 URL 重写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47761605/

相关文章:

c# - Visual Studio 2013发布失败报 "non-existing"错误

asp.net - 如何在另一个打开的aspx页面中设置控件值

asp.net - 使用Visual Studio和Asp.Net Core的Dockerfile错误

c# - MVC4 中的 Html.TextBox 和 Html.Editor 有什么区别?

用于容器的 Azure Web 应用程序 - 没有足够的磁盘空间来启动 Web 应用程序的容器

json - 使用 R 从 API 中提取数据

asp.net - 使用 Website Payments Standard 在 asp.net 网站中集成 Paypal Sandbox

asp.net-mvc - 使用 ID 的 Linq 查询返回结果缓慢(EF Core)

asp.net-mvc - 为级联子列表构建一个空的 MVC DropdownListFor

c# - 是否应该隐藏 Azure Key Vault URL?