IIS 7资源无法找到MVC3

时间:2012-08-23 07:04:33

标签: asp.net-mvc-3

大家好我正试图通过ISS7发布我的网站。我已经部署了所有必需的dll文件但是我得到“无法找到资源”。你能帮帮我吗

Server Error in '/WebCity' Application.
--------------------------------------------------------------------------------

The resource cannot be found. 
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly. 

Requested URL: /WebCity/Views/Home/Index.cshtml


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.272 

2 个答案:

答案 0 :(得分:0)

绝不应将.cshtml文件作为URL请求。

相反,请求一个映射到控制器操作的路径(可能是呈现您试图找到的.cshtml视图的路径),例如。

  

/ WebCity /家庭/索引

答案 1 :(得分:0)

如果查看Global.ascx文件,您将看到默认路由设置,如

  routes.MapRoute(
              "default",
              "{controller}/{action}/{id}",
              new { action = "Index", id = "" }
             )}
            );

因此,您案例中请求的网址将如下所示

/Home/Index
         ^ Controller Action
 ^ Controller

如果您的应用程序部署在localhost,那么它可能看起来像

http://localhost/Home

http://localhost/Home/Index