有什么不对我区在我的仓路由部署MVC4应用程序? [英] What is wrong with my area routing in my bin deployed MVC4 app?

查看:123
本文介绍了有什么不对我区在我的仓路由部署MVC4应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚部署了一个MVC4 .NET 4.0的应用程序到我的虚拟主机,为活的部署测试。非-area路线做工精细,例如我

I have just deployed an MVC4 .NET 4.0 app to my web host, for 'live' deployed testing. Non -area routes are working fine, e.g. my

@Html.ActionLink("Register as a Client", "Register", "Account", new { registrationType = "Client"}, null)

连接工作正常,并且链接打开正确的页面。然而,链接到一个区域基础的行动是这样的:

link works fine, and the link opens the correct page. However, with a link to an area based action like this:

@Html.ActionLink("Authors", "Index", "Home", new { Area = "Author", registrationType = "Author" }, null)

实际上呈现到浏览器链接缺少行动和控制,即

the link actually rendered to the browser is missing action and controller, i.e.

http://mylivedomain.com/?Area=Author&registrationType=Author

这可能是值得一提的是,CSS捆绑MVC4的功能部署后不工作,我回滚到使用经典的款式链接到个人样式表。

It may be worth noting that the css bundling feature of MVC4 was not working after deployment, and I rolled back to using classic style links to individual stylesheets.

可能与:我的问题:为什么我MVC4的应用程序模板未修改code试图两次注册领域

JUST IN:从本区域路由映射默认rouite的默认操作解决了这个问题。有没有默认控制器下手,在VS2012模板code。

JUST IN: Removing the default action from the area route mappings for the default rouite solved this problem. There was no default controller to start with, in the VS2012 template code.

推荐答案

在你的情况,因为您可以指定查询字符串的区域,距离Global.asax.cs中的路线应适用。我相信你有这样的事情有:

In your case because you specify area in query string, the routes from Global.asax.cs should apply. I belive you have something like this there:

    public override void RegisterArea(AreaRegistrationContext context)
    {
        context.MapRoute(
            "Default",
            "{controller}/{action}/{id}",
            new { controller = "Home", action = "Index", id = UrlParameter.Optional }
        ).DataTokens.Add("area","Author");
    }

这code使家庭/索引缺省路由,并在网址跳过首页/索引。如果您在其他例如控制器=什么改变控制器=家庭,家庭2你会全屏显示链接首页/指数和新的默认路由家庭2 /索引。类似的应用到默认路由的地区,如果你有他们的规定。

This code makes Home/Index default route and skips Home/Index in url. If you change controller = "Home" on something else for example controller = "Home2" you will have displayed full link for Home/Index and new default route Home2/Index. Similar apply to default routes in areas if you have them specified.

这篇关于有什么不对我区在我的仓路由部署MVC4应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆