【问题标题】:Browser shows Server Error in '/' Application MVC4浏览器在“/”应用程序 MVC4 中显示服务器错误
【发布时间】:2013-09-25 21:37:54
【问题描述】:

目前我正在使用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 之外的其他页面进行调试时,它工作正常。为什么会这样?能给个解决办法吗?

【问题讨论】:

  • 检查路由并查看名称
  • 检查视图中是否有 index.cshtml/

标签: c# asp.net asp.net-mvc asp.net-mvc-4 razor


【解决方案1】:

我认为您请求的 URL 错误:/Views/Report/Index.cshtml

应该是主机名/报告/索引,即http://localhost/Report/Index

【讨论】:

    【解决方案2】:

    你说错了..

    您的请求模式应如下所示:

    ControllerName/ActionName

    因此您的请求应该是http://localhost/Report/Index

    流程如下:

    1. 什么时候打http://localhost/Report/Index
    2. 您的请求将被重定向到位于ReportController.csIndex Action
    3. 然后Index Action 将返回位于"Views/Report" 文件夹中的Index.cshtml view

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-04-11
      • 1970-01-01
      • 2016-05-10
      • 2017-09-18
      • 2013-01-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多