Displaying External Content In MVC

  • Thread starter Thread starter Karim samir
  • Start date Start date
K

Karim samir

Guest
In this example i have 401 not authorized error in GetResponse() method.

The URL has an authentication required popup, and i want to access to the webpage directly.

public ActionResult Contact()
{
var request = (HttpWebRequest)WebRequest.Create("URL") ;
request.Method = "GET";
var cred = new NetworkCredential("User", "Password","Domain");
var cache = new CredentialCache();
cache.Add(new Uri("URL"), "Basic", cred);
request.Credentials = cache;
var response = (HttpWebResponse)request.GetResponse();
return Redirect(response.ResponseUri.ToString());
}
????

Continue reading...
 
Back
Top