C# ASP MVC允许静态html文件

C# ASP MVC允许静态html文件,c#,html,asp.net,asp.net-mvc,static-files,C#,Html,Asp.net,Asp.net Mvc,Static Files,我有一个简单的ASP MVC项目。 在此站点下,我需要显示plain.html文件,而不将路由视为控制器/操作 我有文件index.html的文件夹文档。 我需要在www.mydomain.com/documentation下访问此文件,它返回403。 目前它只能在www.mydomain.com/documentation/index.html下工作 我补充说 routes.Ignore("developers/"); 进入RouteConfig.cs 在OwinAppBuilder的Sta

我有一个简单的ASP MVC项目。 在此站点下,我需要显示plain.html文件,而不将路由视为控制器/操作

我有文件index.html的文件夹文档。 我需要在www.mydomain.com/documentation下访问此文件,它返回403。 目前它只能在www.mydomain.com/documentation/index.html下工作

我补充说

routes.Ignore("developers/");
进入
RouteConfig.cs

在OwinAppBuilder的
Startup.cs

        app.UseStaticFiles();

我应该怎么做才能在您的路径配置中的www.mydomain.com/documentation/index.html下访问它

routes.RouteExistingFiles = true;
routes.MapRoute(
    name: "staticFileRoute",
    url: "Public/{*file}",
    defaults: new { controller = "Home", action = "HandleStatic" }
);
在web.config的
/
下添加

<add name="MyCustomUrlHandler2" path="Public/*" verb="GET" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
网站,如果您想了解更多信息


编辑:请注意,
MapRoute
中的url在url中以及web.config行的
路径中都有目录
Public
。如果您的html文件不在名为
Public
的目录中,您需要更改该部分以匹配您的目录结构。

您可以为其他静态文件(如.js和.png)提供服务吗?另外,您正在运行哪个版本的IIS?或Core?对于核心,请看:我实际上可以显示文件,问题是我需要显式地将“index.html”写入URL。。。当我禁用所有MVC并让站点运行时,一切正常,这将处理domain.com/documentation/index.html之类的路由。。但我需要相反的方式,我需要将类似domain.com/documentation的URL转换为domain.com/documentation/index.html,以显示html文件请看一下: