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();
}
}
发布您的控制器和global.asax – kd7