我试图做以下事情:
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes){
{
//other stuff
routes.MapRoute(
name: "MyRoute",
url: "test.htm",
defaults: new { controller = "Controller", action = "Test" });
}
}
但IIS在尝试检索example.com/test.htm
的静态文件时返回404。
如何获得理想的效果?
答案 0 :(得分:2)
最终对我有用的解决方案是:
<system.webServer>
<handlers>
<add name="htm to asp" path="*.htm" verb="*" type="System.Web.UI.PageHandlerFactory" resourceType="Unspecified" preCondition="integratedMode" />
</handlers>
</system.webServer>
答案 1 :(得分:0)
这是因为MVC路由在周期中很难。如果您使用的是.NET 4,则可以输入
<httpRuntime relaxedUrlToFileSystemMapping="true"/>
在你的web.config文件中。
以下是解释和更多信息:http://haacked.com/archive/2010/04/29/allowing-reserved-filenames-in-URLs.aspx