托管MVC3应用程序,只有目录列表。路由不工作?

时间:2013-09-10 22:44:11

标签: c# asp.net-mvc-3

好的,所以部署到本地IIS我的项目工作正常。部署到在线主机,我只获得目录列表。

使用VisualStudio 2012,mvc3,.net 4.5 发布到Web设置:

  1. 发布方式:FTP
  2. 服务器:www."mysite".co.za
  3. 网站路径:“空白”(我的理解是我直接发布到app目录,因此我的root包含bin,views,global.asax,web.config)
  4. 目标网址:http://www."mysite".co.za
  5. 数据库已在web.config
  6. 中启动并配置

    如果单击Views目录,我会收到404错误。

    我接下来要做的是查看它是否执行global.asax,所以我添加了代码以在RegisterRoutes中抛出异常(从Application_Start()调用)

        public static void RegisterRoutes(RouteCollection routes)
        {      
          routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
          routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults        
          );
    
          throw new Exception("This is my custom error: Currently in RegisterRoutes");      
        }
    

    真的是Bob,我得到以下内容(但仍然只有当我点击我的View目录时):

    Server Error in '/' Application.

    This is my custom error: Currently in RegisterRoutes

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Exception: This is my custom error: Currently in RegisterRoutes

    所以我的问题:  1.为什么我的root不能获取global.asax?  2.如何在routes.MapRoute(...)之后查看代码执行的结束位置? (也就是说,在删除抛出异常之后;))

    此致

2 个答案:

答案 0 :(得分:1)

这也恰好也是如此。通常这是由于Web配置中缺少某些设置。具体而言,this question提供了答案。编辑Web配置以加载所有请求的所有托管模块。

<system.webServer><modules runAllManagedModulesForAllRequests="true"></modules></system.webServer>

答案 1 :(得分:0)

您可能没有在服务器上注册IIS。请使用aspnet_regiis -i注册,然后检查IIS中应用程序池下的.net版本。

相关问题