【发布时间】:2018-10-31 17:31:28
【问题描述】:
我有一些 HTML 文件存储在一个文件夹中,我想打开这些 HTML 文件。
我在route.config 文件中添加了以下代码:
routes.IgnoreRoute("{file}.html");
routes.MapRoute(
name: "Default",
url: "{about.html}",
defaults: new { controller = "About", action = "Index", id =
UrlParameter.Optional });
现在这个 about.html url 已经创建,并且关于控制器索引操作我称之为视图。所以它正在工作,但我直接从文件夹打开文件然后它没有打开。
我遇到了错误
HTTP 错误 500.0 - 内部服务器错误
内部服务器错误
最可能的原因是:
IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.
IIS was not able to access the web.config file for the Web site or application. This can occur if the NTFS permissions are set incorrectly.
IIS was not able to process configuration for the Web site or application.
The authenticated user does not have permission to use this DLL.
The request is mapped to a managed handler but the .NET Extensibility Feature is not installed.
我希望路径是example.com/Folder/test.html。
【问题讨论】:
-
据我所知,除非文件位于 Views 文件夹中,否则您不需要调整 web.config。例如,如果您有一个文件夹名称“StaticFiles”,那么一个文件“index.html”您应该能够通过yourapp/StaticFiles/index.html 访问它
-
能否分享一下调用html文件的代码。
-
默认情况下,甚至不需要 routes.**IgnoreRoute("{file}.html");**。默认情况下,Asp.Net MVC 能够托管静态 html。无需配置。您的问题必须位于其他地方。我建议您查看您的服务器日志并处理所有异常以确定您的问题到底是什么。查看stackify.com/aspnet-mvc-error-handling 了解如何处理 ASP.Net MVC 中的错误
标签: asp.net-mvc