0
我想在登錄後修改我的HeaderResponse函數。其實我可以修改/添加新的部分在這個響應字段我想修改所有xhr請求的頭部
HttpContext.Response.AddHeader(「Example」,「example」);
但它並不影響所有請求。它隻影響一個請求。
[HttpPost]
[Route("Account/Login")]
[ValidateAntiForgeryToken]
public JsonResult Login(string username, string password)
{
AccountModel am = new AccountModel(username, password);
am.Find(username);
if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password) ||
am.Login(username, password) == null)
{
var data = new { status = "false", message = "Account is Invalid" };
return Json(data,JsonRequestBehavior.AllowGet);
}
////////HttpContext.Response.AddHeader("Example", "example");
return Json(....,JsonRequestBehavior.AllowGet);
}
基本上,我想在登錄進度後創建HeaderResponse。我想,我需要一種HttpGlobalContext.Response或類似的東西。有可能這樣做嗎?或者有沒有其他辦法。
您使用owin標頭值? –
是的,即時通訊使用owin。 – Cracked