none
Displaying External Content In MVC RRS feed

  • Question

  • 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());
            }
    ????

    • Moved by CoolDadTx Monday, March 4, 2019 2:43 PM ASP.NET related
    Monday, March 4, 2019 10:33 AM

All replies