【.net】无法重定向,@Html.AntiForgeryToken() 其他信息: 服务器无法在发送 HTTP 标头之后追加标头。

背景:

      想在登录的时候,满足一定条件的话直接跳转页面,而不是返回当前view()

      当前前端页面中有@Html.AntiForgeryToken(),直接就报错了

 

报错的后台写法:

// GET: Login
        public ActionResult Index() 
{
//获取地址
string order_url = ConfigurationHelper.GetAppSettingValue("order_url").ToString();
Response.Redirect(order_url);
return View();
}

 

 改正后的写法:  【将Response.Redirect(order_url)   改为  return Redirect(order_url);  这样就不会出现错误】

public ActionResult Index()
        {//获取运营分析系统登录首页地址
            string order_url = ConfigurationHelper.GetAppSettingValue("order_url").ToString();
            //获取是否关闭系统自身登录页面的功能 1=关闭  0=不关闭   关闭后将自动跳转到运营分析系统
            string close_self_login = ConfigurationHelper.GetAppSettingValue("close_self_login").ToString();
            if(close_self_login.Equals("1"))
                return Redirect(order_url);
            else
                return View();
        }

 

posted @ 2022-05-25 14:45  狼窝窝  阅读(246)  评论(0)    收藏  举报