Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 身份验证通过后打开响应uri_C#_Asp.net Mvc_Authentication_Ntlm - Fatal编程技术网

C# 身份验证通过后打开响应uri

C# 身份验证通过后打开响应uri,c#,asp.net-mvc,authentication,ntlm,C#,Asp.net Mvc,Authentication,Ntlm,我正在通过MVC应用程序打开一个经过NTLM认证的站点 public ActionResult Login(Credentials data) { Uri queryUrl = new Uri("http://someurl.com"); string domain = "DMZ"; HttpWebRequest req = WebRequest.Create(queryUrl) as HttpWebRequest; NetworkCredential cre

我正在通过MVC应用程序打开一个经过NTLM认证的站点

public ActionResult Login(Credentials data)
{
    Uri queryUrl = new Uri("http://someurl.com");

    string domain = "DMZ";

    HttpWebRequest req = WebRequest.Create(queryUrl) as HttpWebRequest;
    NetworkCredential cred = new NetworkCredential(data.UName, data.Pass, domain);
    var cache = new CredentialCache { { queryUrl, "Ntlm", cred } };
    req.Credentials = cache;
    HttpWebResponse response = req.GetResponse() as HttpWebResponse;


    return Redirect(response.ResponseUri.OriginalString);
    //return View();
}

如果我在返回时设置断点,我会得到响应。状态码为“OK”,身份验证工作正常。但是我不知道如何用身份验证打开url。对于重定向,我再次使用其请求凭据

为什么要这样做?我们有一个使用Ntlm身份验证的uri,当您访问该站点时,它会在默认登录屏幕上询问用户名和密码。我们希望有一个自定义的登录页面,该页面上有协议。