从 ASP.NET MVC 3 升级到 ASP.NET MVC 4 导致 404 错误 [英] Upgrading from ASP.NET MVC 3 to ASP.NET MVC 4 leads to 404 errors

查看:34
本文介绍了从 ASP.NET MVC 3 升级到 ASP.NET MVC 4 导致 404 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚使用 .NET 4.5 将 ASP.NET MVC 3 升级到 ASP.NET MVC 4,根控制器正在工作,但 MVC 区域中的控制器开始出现 404 错误.

I just upgraded ASP.NET MVC 3 to ASP.NET MVC 4 with .NET 4.5 and root controllers were working but controllers in MVC Area started giving 404 errors.

我查找了 IIS 7 QFE 补丁,但它不适用于 windows 8.通过设置断点,我可以看到该区域注册成功,并且在完成注册后,我看到路由集合中注册了 4 个路由,第一个是区域对应的路线.但是任何对区域 url 的请求都会导致 404 错误.

I looked up for IIS 7 QFE patch, but it is not applicable to windows 8. By setting breakpoints, I could see that area was registered successfully and also after complete registration, I see 4 routes registered in routes collection and first one is the route corresponding to area. But any request for area url just falls to 404 error.

推荐答案

我把这个答案留给在升级过程中遇到问题的每个人.

I am leaving this answer for everyone who faces problem during upgrade.

我有一个针对 ASP.NET MVC 3 编译的业务逻辑库(一个不同的 .NET 类库).

I had a business logic library (a different .NET class library) which was compiled against ASP.NET MVC 3.

如果您在 ASP.NET MVC 4 项目中使用对针对 ASP.NET MVC 3 编译的其他库的任何引用,则 Web 服务器不会引发任何错误,而是无法加载依赖于的控制器外部库,因此它不会显示加载错误,而是简单地抛出 404 错误,因为它假定未找到控制器.

If you use any references to other library which was compiled against ASP.NET MVC 3 in ASP.NET MVC 4 project, then web server does not raise any error, but instead it is not able to load controllers that were dependent on external library so instead of showing a loading error, it simply throws 404 error as it assumes that controller was not found.

如果控制器不依赖于针对 MVC3 编译的外部库,则在同一区域定义的控制器运行良好.

Controllers defined in same area worked well if they were not dependent on external library compiled against MVC3.

简而言之,任何控制器,取决于针对 MVC3 编译的任何库中的类型,都不会加载,并且会引发 404 错误".

In short "Any controller, depending upon types from any library compiled against MVC3 will not load, and 404 error will be raised".

理想情况下,它应该引发错误.

Ideally it should have raised an error.

这篇关于从 ASP.NET MVC 3 升级到 ASP.NET MVC 4 导致 404 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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