如何正确的为web.config编写http error code的自定义页面
2015-04-01 17:28
459 查看
备忘。
下面这个subStatusCode,呃,有时很有用的。
以下这一段常常不起作用,所以也就不要用这种方式了。
关于C#就简单了
下面这个subStatusCode,呃,有时很有用的。
<system.webServer> <httpErrors errorMode="Custom"> <remove statusCode="404" subStatusCode="0" /> <error statusCode="404" subStatusCode="0" path="/home/http/404" responseMode="ExecuteURL" /> <remove statusCode="400"/> <error statusCode="400" path="/home/http/400" responseMode="ExecuteURL" /> </httpErrors> </system.webServer>
以下这一段常常不起作用,所以也就不要用这种方式了。
<system.web> <customErrors mode="On" defaultRedirect="/home/http/0"> <error statusCode="404" redirect="/home/http/404" /> <error statusCode="500" redirect="/home/http/500" /> </customErrors> </system.web>
关于C#就简单了
public ActionResult Http(string id) { string viewName = "~/Views/Shared/http" + id + ".cshtml"; if (!System.IO.File.Exists(Server.MapPath(viewName))) { viewName = "~/Views/Shared/Error.cshtml"; } return View(viewName); }
相关文章推荐
- 如何在web.config中存储自定义对象
- java web 自定义错误页面 完整jsp错误页面代码(同时写错误日志) error.jsp
- 如何在HttpWebRequest 里面去触发一个页面的单击事件
- 如何在ASP.NET中制作Web用户自定义控件,并在aspx页面中使用它的方法和属性?
- java web 自定义错误页面 完整jsp错误页面代码(同时写错误日志) error.jsp
- code block error. 在sharepoint aspx 页面中写自定义代码
- .net 如何在web.config中读取自定义节点以及注意的问题(转)
- 关于asp.net(c#),webconfig中如何定义一个字符串让所有页面共同使用?
- 如何在web.config 或者 app.config 文件中配置自定义节点
- 如何编写自定义的Web控件
- 如何在web.config里面设置页面跳转问题
- 自定义HttpHandler中如何调用页面默认的HttpHandler对象。
- web.config 自定义错误页面
- 如何将Web应用打包成.war文件? 转自:http://blog.csdn.net/code_JAVA/archive/2008/05/19/2457749.aspx
- 找不到好的方法,如何通过HttpWebRequest获取页面的Encoding。(转)
- 提问:自定义web.config时如何定义架构(Schema)
- 问题:C++编写的核心模块如何暴露给外部HTTP Web服务接口???
- 手动设置 HttpStatusCode 后 Web.config 中 CustomErrors 无效的情况
- 在ASP.NET MVC 如何在Response.StatusCode = 404的同时,显示友好的自定义错误页面
- WebView加载自定义error页面,解决自定义error页面但是原始error页面一闪而过的问题