解决404.13

Don‘t use runAllManagedModulesForAllRequests="true" when getting your MVC routing to work

It seems to be common advice to make your modules section of your web.config say <modules runAllManagedModulesForAllRequests="true">. In fact this is quite a drastic thing to do to solve the routing problem and has global effects that could CAUSE ERRORS.

You need a module that goes by the name of UrlRoutingModule-4.0 to be running through IIS. Now, since your MVC URLs are likely to end without .aspx these will not be picked up by IIS and run through the intergrated pipeline and therefore you will end up with 404 not found errors. I struggled with this when I was getting started until I found the <modules runAllManagedModulesForAllRequests="true"> workaround.

This highly recommended fix can cause other problems. These problems come in the form of making all your registered HTTP modules run on every request, not just managed requests (e.g. .aspx). This means modules will run on ever .jpg .gif .css .html .pdf etc.

This is:

  1. a waste of resources if this wasn‘t the intended use of your other modules
  2. a potential for errors from new unexpected behaviour.

Better solution

Fine, so the ranting about <modules runAllManagedModulesForAllRequests="true"> is over. What is a better solution?

In the modules section of your web.config, you can add the UrlRoutingModule-4.0 module in with a blank precondition meaning it will run on all requests. You will probably need to remove it first since it is most likely already registered at machine level. So make your web.config look like this:

<modules>
  <remove name="UrlRoutingModule-4.0" />
  <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" preCondition="" />
  <!-- any other modules you want to run in MVC e.g. FormsAuthentication, Roles etc. -->
</modules>

Note: the modules element does NOT contain the runAllManagedModulesForAllRequests="true" attribute because it is evil!

时间: 2024-10-29 13:26:56

解决404.13的相关文章

HTTP 错误 404.13 - Not Found 请求筛选模块被配置为拒绝超过请求内容长度的请求

问题:HTTP 错误 404.13 - Not Found 请求筛选模块被配置为拒绝超过请求内容长度的请求. 原因:Web 服务器上的请求筛选被配置为拒绝该请求,因为内容长度超过配置的值(IIS 7 默认文件上传大小时30M). 解决:更改asp.net文件上传大小限制 1. 修改IIS的applicationhost.config 文件位置: %windir%/system32/inetsrv/config/applicationhost.config 找到<requestFiltering>

解决ubuntukylin 13.10安装wine时无法解决软件包依赖问题

在ubuntukylin 13.10中,无论是在软件中心安装wine还是通过apt-get install安装wine都会出现软件包依赖问题且无法解决. 问题重现 在软件中心安装wine报错例如以下: wine1.4: PreDepends: dpkg (>= 1.15.7.2~) but 1.16.7ubuntu6 is to be installed Depends: libc6 (>= 2.14) but 2.15-0ubuntu20 is to be installed Depends

Eclipse添加tomcat服务器以及解决404的问题

Eclipse JavaEE IDE添加tomcat服务器 1. 先做准备工作,首先下载工具 点击下方链接下载     1) Tomcat v7.0     2) Eclipse IDE for Java EE Developers     3)Java SE Development Kit 下载完后安装,这里安装就省略一万字啊! 2. 添加tomcat服务器 打开你装好的Eclipse 1)选择菜单  Window --> Preferences-->Server -->Runtime

开发过程中 解决404错误

在初学阶段,经常遇到页面跳转404的错误,总结一下几点  ,希望有所帮助 检查url是否对应,服务器端口号,映射的url,参数是否对应 检查容器是否初始化,如:注解是否正确,配置文件是否扫描到, .检查配置文件,如:web.xml,关键词是否对应,或者有没有写 检查虚拟机,查看ip地址是否正确,以及虚拟机是否开启 原文地址:https://www.cnblogs.com/coderwsp/p/10742446.html

springmvc的DispatcherServlet拦截以及访问静态资源html、js、css 404问题

之前一直使用*.do来做的,但是绝的*.do很丑,于是就改用“/”来配置: 1 2 3 4 5 6 7 8 9 10 <servlet>      <servlet-name>dispatcherServlet</servlet-name>      <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>      <load-on-s

spring mvc 静态资源 404问题

spring mvc 静态资源 404问题 在web.xml配置servlet-mapping的时候,如果url-pattern设置为"/" (如下),很多人都会遇到导入js,css,图片等静态资源出现Firefox调试窗口会报出的404错误,而你的确也不能访问那些资源 <servlet-mapping> <servlet-name>dispatcherServlet</servlet-name> <url-pattern>/</u

css-兼容性问题及解决(二)

css-兼容性问题及解决(二) 1:在IE6下的文字溢出BUG : 子元素的宽度和父级的宽度相差小于3px的时候,两个浮动元素中间有注释或者内嵌元素       解决办法:用div把注释或者内嵌元素用div包起来 1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

atitit.404错误的排查流程总结vOa6

1. 场景 1 1.1. 子应用猛个腊擦不能使用  404 兰.. 1 2. 服务器配置问题 2 2.1. 登录服务器管理子应用,查看应用是否启动okk???? 2 2.2. 80端口已经占用,实际访问的在的服务器端口 2 2.3. #----------jsp  head  errorPage="" 2 2.4. 应用冲突::同时部署了根应用and子应用.. 2 2.5. #------resin 服务器配置问题.俩个应用配置到了同样的的文件夹.. 2 2.6. #---------

Win7 IIS 部署站点遇到的问题 如 HTTP 错误 404.XX

HTTP 错误 404.2 - Not Found 由于 Web 服务器上的“ISAPI 和 CGI 限制”列表设置,无法提供您请求的页面. 解决办法:设置为允许 ======================================================================= HTTP 错误 404.17 - Not Found "HTTP 错误 404.17 - Not Found 请求的内容似乎是脚本,因而将无法由静态文件处理程序来处理." 运行cmd