ASP.Net MVC 2 领域:部分视图“...”没有找到

发布于 2024-09-25 04:44:44 字数 1087 浏览 3 评论 0原文

我们最近将一个项目升级到 MVC 2,我们想使用区域,但有一个问题。

我们创建了一个新区域,设置了一个控制器,配置了一条路线,并在正确的位置创建了一个视图。当我们运行代码时,它成功找到路线并命中控制器,但当它去渲染视图时出现异常。

Web 表单视图引擎似乎没有在“区域”部分中查找视图。我们看到的错误是:

~/Views/<ControllerName>/<ViewName>.aspx
~/Views/<ControllerName>/<ViewName>.ascx
~/Views/Shared/<ViewName>.aspx
~/Views/Shared/<ViewName>.ascx

应该是:

~/<AreaName>/Views/<ControllerName>/<ViewName>.aspx
~/<AreaName>/Views/<ControllerName>/<ViewName>.ascx
~/<AreaName>/Views/Shared/<ViewName>.aspx
~/<AreaName>/Views/Shared/<ViewName>.ascx
~/Views/<ControllerName>/<ViewName>.aspx
~/Views/<ControllerName>/<ViewName>.ascx
~/Views/Shared/<ViewName>.aspx
~/Views/Shared/<ViewName>.ascx

这表明它仍在以某种方式使用 MVC 1 dll,但我们仔细查看并且只能找到对 MVC V2 的引用(那里是第三方 DLL xVal 中的 V1 引用,但修复它并没有什么区别)。

我只能想象我们在升级时错过了一些东西,或者我们遇到了一些不寻常的边缘情况,因为网络上似乎没有任何内容与我们遇到的问题相匹配。

我们可以看看哪些事情可以帮助我们解决这个问题?

预先感谢您提供的任何帮助。 干杯, 扎克

We recently upgraded a project to MVC 2 and we'd like to use Areas but there is an issue.

We have created a new area, setup a controller, configured a route, and created a view in the correct location. When we run the code it successfully finds the route and hits the controller but when it goes to render the view there is an exception.

The web forms view engine doesn't seem to be looking in the Areas section for views. The error we're seeing is:

~/Views/<ControllerName>/<ViewName>.aspx
~/Views/<ControllerName>/<ViewName>.ascx
~/Views/Shared/<ViewName>.aspx
~/Views/Shared/<ViewName>.ascx

When it should be:

~/<AreaName>/Views/<ControllerName>/<ViewName>.aspx
~/<AreaName>/Views/<ControllerName>/<ViewName>.ascx
~/<AreaName>/Views/Shared/<ViewName>.aspx
~/<AreaName>/Views/Shared/<ViewName>.ascx
~/Views/<ControllerName>/<ViewName>.aspx
~/Views/<ControllerName>/<ViewName>.ascx
~/Views/Shared/<ViewName>.aspx
~/Views/Shared/<ViewName>.ascx

This would indicate that it's still somehow using the MVC 1 dll but we've looked carefully and can find only references to the V2 of MVC (there was a V1 reference in xVal, a third party DLL, but fixing that didn't make a difference).

I can only imagine that we missed something when we did the upgrade or that we've got some unusual edge case because there doesn't seem to be anything on the web that matches the problem we're experiencing.

What things could we look at that might help us resolve this issue?

Thanks in advance for any help provided.
Cheers,
Zac

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

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

发布评论

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

评论(1

煞人兵器 2024-10-02 04:44:44

我们可以考虑哪些因素来帮助我们解决这个问题?

  1. 确保首先注册区域路由 AreaRegistration.RegisterAllAreas();。区域路线也需要注册。
  2. 使用 ActionLink 和其他相关 URL 帮助程序时,确保生成的 URL 链接包含区域名称作为参数之一。
  3. 有时只需从头开始删除并重新添加区域即可。听起来很傻,但确实有效。
  4. 本页左侧的相关问题可能会有所帮助。我已经链接了一个我认为可能有价值的链接

What things could we look at that might help us resolve this issue?

  1. Make sure Area Routes are Registered AreaRegistration.RegisterAllAreas(); are registered first. Area routes need to be registered as well.
  2. Make sure generated URL links have the area name included as one of the arguments when using ActionLink and other related URL helpers
  3. Sometimes just delete and re-add the Area from scratch. Sounds silly, but it works.
  4. The related SO question on the left hand side of this page may help. I have linked one I think may be of value
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文