解决:无法在发送 HTTP 标头之后进行重定向。 跟踪信息: 在 System.Web.HttpResponse.Redirect(String url, Boolean endResponse, Boolean permanent) 在 System.Web.Mvc.Async.AsyncControllerActionInvoker.<>……
public class Logged : ActionFilterAttribute, IAuthorizationFilter
{
………略………
public void OnAuthorization(AuthorizationContext filterContext)
{
string openid = XXXXXX.GetOpenId();//在获取openid时XXXXXX.GetOpenId()已经跳转,代码略 if (string.IsNullOrEmpty(openid))
{
filterContext.Result = new RedirectResult("https://www.****.com/login");//在获取openid时页面已经跳转,这里就不要再次跳转了,否则报错:无法在发送 HTTP 标头之后进行重定向。
return;
}
………略………
}
………略………
}
修改后的代码:
public class Logged : ActionFilterAttribute, IAuthorizationFilter
{
………略………
public void OnAuthorization(AuthorizationContext filterContext)
{
string openid = XXXXXX.GetOpenId();//在获取openid时XXXXXX.GetOpenId()已经跳转 if (string.IsNullOrEmpty(openid))
{
filterContext.Result = new ContentResult();//终止Action继续向下执行
return;
}
………略………
}
………略………
}
解决:无法在发送 HTTP 标头之后进行重定向。 跟踪信息: 在 System.Web.HttpResponse.Redirect(String url, Boolean endResponse, Boolean permanent) 在 System.Web.Mvc.Async.AsyncControllerActionInvoker.<>……的更多相关文章
- Response.Redirect引起的“无法在发送HTTP标头之后进行重定向”
博客后台切换至i.cnblogs.com之后,在日志中发现大量的“无法在发送HTTP标头之后进行重定向”(Cannot redirect after HTTP headers have been se ...
- 出现“无法在发送 HTTP 标头之后进行重定向”问题
如题,在Response.Redirect之后会偶尔出现“无法在发送HTTP标头之后进行重定向”问题. 是因为,已经在出现错误的代码之前进行过一次重定向了.仔细检查代码即可. 解决方法:按照逻辑移除多 ...
- 处理 ASP.NET 中的异常:无法在发送 HTTP 标头之后进行重定向。
因为在 Global.asax 中的 Application_Error 事件中添加了统一的错误处理,其中会有 Redirect 重定向到错误页面. 但是有可能有些情况下已经进行过其它重定向操作,所以 ...
- C# 无法在发送 HTTP 标头之后进行重定向
在调试中发现错误如下: Response.Redirect引起的“无法在发送HTTP标头之后进行重定向” 跳转失败 解决方案如下: 使用js方法来跳转地址 const string url=" ...
- Page.Response.Buffer与Response.Redirect一起用报错“无法在发送 HTTP 标头之后进行重定向”
Page.Response.Buffer与Response.Redirect一起用报错“无法在发送 HTTP 标头之后进行重定向” 原因还未知..
- Response.Redirect:无法在发送 HTTP 标头之后进行重定向
URL:http://blog.163.com/asp_neter/blog/static/17510918820107258107558/ 错误出现语句:“Response.Redirect(&qu ...
- MVC开发中的常见错误-06-"无法在发送 HTTP 标头之后进行重定向。"
通过监视可以看到: 原来是跳转到登录页面后,登录页面中又发送了一个GeMneuItems的请求,用于加载页面图片
- 无法在发送 HTTP 标头之后进行重定向
public ActionResult Index2() { Response.Buffer = true; Response.Clear(); return Redirect("/Wech ...
- 关于MVC中 服务器无法在发送 HTTP 标头之后修改 cookie此类问题的解决
处理方法 使用过滤器控制权限时,若无权则跳转到无权页面,但是每次跳转都会出现 ERROR - System.Web.HttpException (0x80004005): 服务器无法在已发送 HTTP ...
随机推荐
- Haskell语言学习笔记(41)Parsec(1)
Parsec Parsec是一个词法及语法分析器. 匹配字符与字符串 Prelude Text.Parsec> parseTest anyChar "a" 'a' Prelu ...
- Quartz+TopShelf实现Windows服务作业调度
Quartz:首先我贴出来了两段代码(下方),可以看出,首先会根据配置文件(quartz.config),包装出一个Quartz.Core.QuartzScheduler instance,这是一个调 ...
- Python的isdigit()和isalpha()
提供一个参考链接<isalpha() Method> 使用isdigit()判断是否是全数字: if word.encode( 'UTF-8' ).isdigit() 使用isalpha ...
- 使用robotium对android应用进行自动化测试
所需要的环境: 1.eclipse 2.android development tools(ADT) 3.software develoment kit(SDK) 4.JDK 5.robotium 1 ...
- 显示AVI文件的桢数
procedure TForm1.Button1Click(Sender: TObject);begin MediaPlayer1.TimeFormat := tfFrames; ShowMess ...
- Hibernate实体映射转换列值
@Column(name="ADDTIME", insertable=false, updatable=false)@ColumnTransformer(read="CA ...
- Intersection(Check)
Intersection http://poj.org/problem?id=1410 Time Limit: 1000MS Memory Limit: 10000K Total Submissi ...
- asp.net后台解析JSON,并将值赋给对象
示例代码如下: using System; using System.Collections.Generic; using System.Web.Script.Serialization; publi ...
- ios8 UITableView section不显示
ios8 如果UITableView只设置viewForHeaderInSection,则可能section不能显示,iOS7及以下版本显示正常. 解决方案: 设置heightForHeaderInS ...
- 18-从n个数中选m个
#include <iostream>using namespace std; int f(int n, int m){ if(n < m) //这个条 ...