.net 在配置文件中配置404路径出错
来源:互联网 发布:tv007网络电视在线直播 编辑:程序博客网 时间:2024/06/05 15:49
//
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new CustomHandlerErrorAttribute());
}
//创建一个普通类。继承一个错误过滤器接口
public class CustomHandlerErrorAttribute : HandleErrorAttribute
{
public override void OnException(ExceptionContext filterContext)
{
if (filterContext.ExceptionHandled)
{
return;
}
filterContext.Controller.ViewData.Model = filterContext.Exception;
filterContext.Result = new ViewResult
{
ViewName = "Error",
ViewData = filterContext.Controller.ViewData
};
filterContext.ExceptionHandled = true;
}
}
//在配置文件的下面 web.config <system.web>
<customErrors mode="On">
<error redirect="/home/error" statusCode="404" />
</customErrors>
//web.config <system.webServer>
<httpErrors errorMode="Custom" existingResponse="PassThrough">
</httpErrors>
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new CustomHandlerErrorAttribute());
}
//创建一个普通类。继承一个错误过滤器接口
public class CustomHandlerErrorAttribute : HandleErrorAttribute
{
public override void OnException(ExceptionContext filterContext)
{
if (filterContext.ExceptionHandled)
{
return;
}
filterContext.Controller.ViewData.Model = filterContext.Exception;
filterContext.Result = new ViewResult
{
ViewName = "Error",
ViewData = filterContext.Controller.ViewData
};
filterContext.ExceptionHandled = true;
}
}
//在配置文件的下面 web.config <system.web>
<customErrors mode="On">
<error redirect="/home/error" statusCode="404" />
</customErrors>
//web.config <system.webServer>
<httpErrors errorMode="Custom" existingResponse="PassThrough">
</httpErrors>
0 0
- .net 在配置文件中配置404路径出错
- 在.net中配置身份验证时出错
- tomcat在conf中配置工程路径配置文件写法
- 在.NET中自定义配置文件
- 在.NET中自定义配置文件
- 在web.xml中配置文件路径classpath
- 在配置文件中配置国际化
- hibernate在配置文件中配置对象关系映射文件即hbm文件路径的写法
- 使用Visual Studio开发ASP.NET应用程序后在IIS中配置出错的问题
- Mybatis中在配置文件中配置别名
- 动态配置配置文件路径
- 在.NET中自定义配置文件(转)
- 在vb.NET 中使用配置文件
- 在WebSphere7中配置Seam2的配置文件
- 在配置文件中配置USE的数据源
- 动态设置SSIS中,配置包的xml配置文件路径
- 项目中配置文件路径
- Struts2中配置文件在非默认路径下的加载
- 什么是矩阵的迹
- ps命令
- Java面向对象的一些注意事项
- oracle存储过程语法
- HDU 5918 Sequence I【暴力+剪枝】(2016中国大学生程序设计竞赛(长春)H题)
- .net 在配置文件中配置404路径出错
- Linux目录结构及解释(带图)
- c++ 字符串
- px和em,rem,pt的区别
- 文章标题
- Insert into a Cyclic Sorted List
- DB2 LOAD的三种模式 COPY NO, COPY YES和NONRECOVERABLE
- ubuntu12.04下配置NAT网络方式
- linux下清空连接跟踪表的方法