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

问题描述

我刚刚将ASP.NET MVC 3升级到具有.NET 4.5的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修补程序,但不适用于Windows8.通过设置断点,我可以看到该区域已成功注册,并且在完成注册之后,我看到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错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 09:08