浏览器在“/”应用程序 MVC4 中显示服务器错误
本文关键字:显示 服务器 错误 MVC4 应用程序 浏览器 | 更新日期: 2023-09-27 18:32:38
目前我正在使用MVC4
.我有疑问,我试图在index.cshtml
打开时进行调试,它显示了Server Error in '/' Application
.
找不到资源。
说明:HTTP 404.
要查找的资源(或其依赖项之一)可能已被删除、名称已更改或暂时不可用。 请查看以下 URL 并确保拼写正确。
Requested URL: /Views/Report/Index.cshtml
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929.
当我使用index.cshtml
以外的其他页面进行调试时,它工作正常。为什么会这样?你能给出解决方案吗?
我认为您请求了错误的URL:/Views/Report/Index.cshtml
它应该是主机名/报告/索引,即 http://localhost/Report/Index
你叫错了。
您的请求模式应如下所示:
ControllerName/ActionName
因此,您的要求http://localhost/Report/Index
流程如下:
- 什么时候你会打
http://localhost/Report/Index
- 您的请求将被重定向到位于
ReportController.cs
的Index Action
- 然后
Index Action
将返回位于"Views/Report"
文件夹中的Index.cshtml
view
。