ASP.Net MVC 2 领域:部分视图“...”没有找到
我们最近将一个项目升级到 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AreaRegistration.RegisterAllAreas();
。区域路线也需要注册。ActionLink
和其他相关 URL 帮助程序时,确保生成的 URL 链接包含区域名称作为参数之一。AreaRegistration.RegisterAllAreas();
are registered first. Area routes need to be registered as well.ActionLink
and other related URL helpers