asp.net mvc中在Filter中跳转千万不要使用Response.Redirect
来源:互联网 发布:游戏王巅峰知乎 编辑:程序博客网 时间:2024/05/30 13:43
如题,如果在Filter中用Response.Redirect,虽然URL是跳转了,但是之后的Filter和Action还是会执行,不仅浪费资源,还会产生一些不必要的错误,或许,这些错误仅在你的错误日志中能看到。
在Filter中错误使用跳转如下:
filterContext.HttpContext.Response.Redirect(string.Format("{0}#{1}",
filterContext.HttpContext.Request.Url.
AbsolutePath,
filterContext.HttpContext.Request.
QueryString["r_Anchor"]));
filterContext.HttpContext.Response.Redirect就会产生后遗症,正确使用应该是:
filterContext.Result = new RedirectResult(string.Format("{0}#{1}",
filterContext.HttpContext.Request.Url.
AbsolutePath,
filterContext.HttpContext.Request.
QueryString["r_Anchor"]));
正确代码:
- asp.net mvc中在Filter中跳转千万不要使用Response.Redirect
- asp.net中Response.write与Response.Redirect同时使用
- .net 中使用Response.Redirect 在新页面打开
- ASP.NET MVC中Filter使用
- ASP.NET MVC中Filter使用
- 在Updatepanel中使用Response.Redirect
- mvc 使用response.redirect跳转地址问题
- ajax中使用Response.Redirect asp.net 网站中使用ajax控件
- asp.net 在使用Response.Redirect try{}catch{}块失效
- asp.net 在使用Response.Redirect try{}catch{}块失效
- [原创]ASP.NET中Response.Redirect()方法深度剖析
- ASP.NET中Response.Redirect()方法深度剖析(转)
- asp.net中Server.Transfer和Response.Redirect的区别
- ASP.NET中Response.Redirect()方法深度剖析[转]
- ASP.NET中Response.Redirect()方法剖析
- [Asp.net mvc] 在Asp.net mvc 中使用MiniProfiler
- ajax中使用Response.Redirect
- 在Asp.net MVC中使用Repeater
- Mechanics of USB cable and connector
- GLSL 第一个代码
- HTML !DOCTYPE 标签
- Error: Unable to open class file R.java
- Tomcat启动时报ClassNotFoundException while loading persisted sessions: java.lang.ClassNotFoundException: com.xxx.pojo.Admin错误
- asp.net mvc中在Filter中跳转千万不要使用Response.Redirect
- Select sql的效率
- Spring v3.0.2 Learning Note 2 - A Sample Example
- 日语学习
- Spring v3.0.2 Learning Note 3 - Initialisation of Beans
- 移动硬盘出现乱码文件夹的解决方法
- Spring v3.0.2 Learning Note 4 - Scope of Beans
- 访问资源文件方式与访问工作目录
- 在SM中4种调试的方法