asp.net-mvc – Asp.net MVC 3路由区域失败
发布时间:2020-05-24 22:52:11 所属栏目:asp.Net 来源:互联网
导读:我有这条路线: 我在WebSite / Global.asax.cs上的网站路线: namespace WebSite{ public class MvcApplication : HttpApplication { public static void RegisterRoutes(RouteCollection routes) { ro
|
我有这条路线: 我在WebSite / Global.asax.cs上的网站路线: namespace WebSite
{
public class MvcApplication : HttpApplication
{
public static void RegisterRoutes(RouteCollection routes) {
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
...
routes.MapRoute(
"Default","Authenticated/{controller}/{action}/{id}",new { controller = "Home",action = "Index",id = UrlParameter.Optional },new[] { "WebSite.Controllers" }
);
...
}
void Application_Start()
{
...
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
...
}
}
}
我在WebSite / Areas / Admin / AdminAreaRegistration.cs上的管理区路由: namespace WebSite.Areas.Admin
{
public class AdminAreaRegistration : AreaRegistration
{
public override string AreaName
{
get
{
return "Admin";
}
}
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Admin_default","qwerty/Admin/{controller}/{action}/{id}",new { action = "Index",new[] { "WebSite.Areas.Admin.Controllers" }
);
}
}
}
我的网址: WebSite: http://www.mywebsite.com/Authenticated/Controller/Action... Admin: http://www.mywebsite.com/qwerty/Admin/Controller/Action... 我的问题: 使用WebSite URL,我可以从管理区域调用控制器/操作,而不使用“qwerty / Admin”,这是不对的.我怎样才能解决这个问题? 谢谢. 解决方法只需在每个MapRoute之后输入此代码即可.它应该工作!.DataTokens["UseNamespaceFallback"] = false; (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – system.web.compilation.debug与system.codedom
- 在Build上自动停止/重新启动ASP.NET开发服务器
- asp.net-mvc – asp.net MVC DisplayTemplates和EditorTemp
- asp.net – web.config文件设置是否覆盖IIS设置?
- asp.net – 如何使用自定义CSS与我的Sharepoint WebPart?
- asp.net – 如何在aspx文件中创建区域?
- webforms – ASP.NET Web窗体(4.5)强类型模型绑定 – ListV
- asp.net – 如何添加jQuery UI按钮图标到输入按钮?
- asp.net-mvc – 当注入服务或控制器的依赖关系太多时,重构策
- asp.net-mvc – 使用Html.BeginForm发布到当前控制器
推荐文章
站长推荐
- asp.net – 在页面加载中实现IsPostBack
- asp.net – web.config和machine.config之间的区
- asp.net-mvc – 如何创建ASP.NET MVC区域作为插件
- iis-6 – Asp.net mvc 4 on iis6:“无法找到该页
- asp.net-mvc-4 – MVC4 MEF插件和控制器命名空间
- asp.net-mvc – 发送电子邮件是否属于应用程序的
- asp.net-mvc-3 – 方法“OrderBy”必须在方法“跳
- asp.net-mvc-3 – 访问帮助程序中的全局页面变量
- asp.net – SQL Server查询从ADO.NET运行速度比S
- ASP.NET MVC 3中的当前年份
热点阅读
