使用多个项目的 ASP.NET MVC 区域应用程序

发布于 2024-08-15 05:39:43 字数 872 浏览 11 评论 0原文

我一直在关注本教程:

http:// msdn.microsoft.com/en-us/library/ee307987(VS.100).aspx#registering_routes_in_account_and_store_areas

并有一个像这样设置的应用程序(稍微复杂一点)。所有区域都工作正常,但是我注意到,如果我将帐户项目的项目名称更改为 Areas.Accounts,则由于区域名称与帐户项目不同,它不会在帐户项目中找到我的任何视图项目名称,例如账户的routes.cs 文件仍然有这个:

public override string AreaName
    {
        get { return "Accounts"; }
    }

有谁知道为什么我必须将其更改为:

public override string AreaName
    {
        // Needs to match the project name?
        get { return "Areas.Accounts"; }
    }

为了让我在账户项目中的视图正常工作?

我真的希望 AreaName 仍然是 Accounts,但是当 ASP.net MVC 全部合并到一个项目中时,请在“Views\Areas\Areas.Accounts\”文件夹中查找,而不是尝试在“View\区域\帐户\"

谢谢 标记

I have been following this tutorial:

http://msdn.microsoft.com/en-us/library/ee307987(VS.100).aspx#registering_routes_in_account_and_store_areas

and have an application (a bit more complex) like this set up. All the areas are working fine, however I have noticed that if I change the project name of the Accounts project to say Areas.Accounts, that it wont find any of my views within the accounts project due to the Area name not being the same as the project name e.g. the accounts routes.cs file still has this:

public override string AreaName
    {
        get { return "Accounts"; }
    }

Does anyone know why I would have to change it to this:

public override string AreaName
    {
        // Needs to match the project name?
        get { return "Areas.Accounts"; }
    }

for my views in the accounts project to work?

I would really like the AreaName to still be Accounts, but for ASP.net MVC to look in the "Views\Areas\Areas.Accounts\" folder when its all munged into one project, rather than trying to find it within "View\Areas\Accounts\"

Thanks
Mark

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

離殇 2024-08-22 05:39:43

如果我离得还很远,请原谅我,我最近才开始接触 MVC 2.0(当我被拉去从事其他事情时,我并没有与 MVC 1.0 走得太远)...

我有一种感觉您的代码中会自动连接,当您更改项目名称时,无论连接做什么都不会检测/理解更改。我假设在某个地方路由查找没有建立连接,因此您被迫使用详细名称。只是基于有多少软件包的存在似乎只是为了处理连接事件、操作和其他所有内容。

Forgive me if I'm way off, I've only recently started into MVC 2.0 (and I wasn't that far along with MVC 1.0 when I was pulled away to work on something else)...

I have the feeling that something in your code is auto-wiring for you, and when you changed the project name, whatever did the wiring isn't detecting/understanding the change. I assume somewhere the route look-up just isn't making the connection so you're forced to use the verbose name. Just a thought based on how many packages out there seem to exist just to handle wiring up events, actions, and everything else.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文