如何在 asp.net mvc 中重定向时通过 header 传递凭据

How to pass credentials through header on redirect in asp.net mvc

当您从一个页面重定向到另一个页面时,您可以传递 header 中的值或将其保存在浏览器缓存中。

以下代码是关于如何将 header 值从 mvc 站点发送到另一个站点。

  • 在 MVC 中更改默认 Return 类型 "Action Result" 到 "Void"
  • 执行 HTTPPOST 操作。

    [HttpPost] public无效关于() { 字符串 appURL = "http://google.co.in"; Response.AppendHeader("Username", "user123"); Response.AppendHeader("Password", "password"); Response.Status = "301 永久移动"; Response.AppendHeader("Location", appURL); Response.End(); }