C# ASP.NET表单身份验证-返回带有JSON响应的身份验证Cookie

C# ASP.NET表单身份验证-返回带有JSON响应的身份验证Cookie,c#,asp.net,cookies,forms-authentication,C#,Asp.net,Cookies,Forms Authentication,我正试图以编程方式登录到我自己的web应用程序来执行一些屏幕抓取操作,以便运行一些自动化测试。当前,当用户登录系统时,调用以下方法: [HttpPost] public ActionResult Login(LoginModel model, string returnUrl) { // login logic -- ASP.NET Forms Authentication // do i need to send more back here? or change my retur

我正试图以编程方式登录到我自己的web应用程序来执行一些屏幕抓取操作,以便运行一些自动化测试。当前,当用户登录系统时,调用以下方法:

[HttpPost]
public ActionResult Login(LoginModel model, string returnUrl) {
   // login logic -- ASP.NET Forms Authentication
   // do i need to send more back here? or change my return?
   return this.Json(new { resultText = "Success", ReturnUrl = returnUrl });
}
是否有某种方法可以让我在这里返回所需的信息,以便使用响应的代码可以存储这些信息,然后将其与后续请求一起发送回去

HttpWebRequest request = WebRequest.Create(loginUrl) as HttpWebRequest;
// login request comes back successful

HttpWebResponse httpResponse = request .GetResponse() as HttpWebResponse;
// read authentication info here from response

HttpWebRequest request2 = WebRequest.Create(pageUrl) as HttpWebRequest;
// include authentication info here
。。。还是我完全走错了路