2011-11-22 75 views
0

這是我第一次在IIS 7.X上部署asp.net mvc應用程序。asp.net mvc 3頁面找不到

如果我在根路徑上部署應用程序,那麼它工作正常,但如果我部署在非根路徑下面提到的那麼只有我的主頁工作,沒有其他鏈接工作。

http://rootpath/MyApplication/

現在讓我們說,我有控制器 - 與myController的行動 - MyAction。在執行它時,我期待http://rootpath/MyApplication/MyController/MyAction,但它只指向根路徑。 (電流輸出 - http://rootpath/MyController/MyAction

我沒有更改默認路由。我用「文件系統」選項發佈了該網站。

/////// Code of Global.asax /////// 
public class MvcApplication : System.Web.HttpApplication 
    { 
     public static void RegisterGlobalFilters(GlobalFilterCollection filters) 
     { 
      filters.Add(new HandleErrorAttribute()); 
     } 

     public static void RegisterRoutes(RouteCollection routes) 
     { 
      routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 

      bool isBypassOn = false; 

      if (!isBypassOn) 
      { 
       //Following should be default application route path 
       routes.MapRoute(
        "Default", // Route name 
        "{controller}/{action}/{id}", // URL with parameters 
        new { controller = "Login", action = "Index", id = UrlParameter.Optional } // Parameter defaults 
       ); 
      } 
      else 
      { 
       routes.MapRoute(
        "Default", // Route name 
        "{controller}/{action}/{id}", // URL with parameters 
        new { controller = "ByPassLogin", action = "Index", id = UrlParameter.Optional } // Parameter defaults 
       ); 

      } 
     } 

     protected void Application_Start() 
     { 
      AreaRegistration.RegisterAllAreas(); 

      RegisterGlobalFilters(GlobalFilters.Filters); 
      RegisterRoutes(RouteTable.Routes); 
     } 
    } 

//一些控制器代碼

公共類MemberHomeController:BaseController {// // GET:/ MemberHome/

public ActionResult Index() 
    { 
     //return Content("Successful Login..."); 
     return View(); 
    } 

    public override void Custom_OnLoad() 
    { 
     SelectedMenu = Menus.Home; 
    } 

    public ActionResult ScheduleIndex() 
    { 
     //return Content("Successful Login..."); 
     return View(); 
    } 
} 
+0

發佈您的控制器和global.asax – kd7

回答

0

嘗試

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

代替的默認值。