求助:无法在发送 HTTP 标头之后进行重定向

瘦马 2017-04-25 10:07:04

…………
/// <summary>
/// 异常处理
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Application_Error(object sender, EventArgs e)
{
Exception ex = this.Context.Server.GetLastError();
if (ex != null)
{
//登录是否过期
if (!ManageProvider.Provider.IsOverdue())
{
HttpContext.Current.Response.Redirect("~/Login/Default");
}
Dictionary<string, string> modulesError = new Dictionary<string, string>();
modulesError.Add("发生时间", DateTime.Now.ToString());
modulesError.Add("错误描述", ex.Message.Replace("\r\n", ""));
modulesError.Add("错误对象", ex.Source);
modulesError.Add("错误页面", "" + HttpContext.Current.Request.Url + "");
modulesError.Add("浏览器IE", HttpContext.Current.Request.UserAgent);
modulesError.Add("服务器IP", NetHelper.GetIPAddress());
Application["error"] = modulesError;
HttpContext.Current.Response.Redirect("~/Error/Index");//此处出错
}
}


一个MVC WEB项目,Global.asax.cs运行时出错,出错的地方是以上
HttpContext.Current.Response.Redirect("~/Error/Index");/这个地方
求救。
...全文
300 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
正怒月神 2017-04-25
  • 打赏
  • 举报
回复
我记得这个问题不影响运行。试试看增加下面这句呢 HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Redirect("~/Error/Index");

110,545

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧