Last post Mar 05, 2019 05:26 AM by yogyogi
None
0 Points
11 Posts
Mar 04, 2019 11:37 AM|samirkarim|LINK
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()); }
?????
All-Star
57884 Points
15516 Posts
Mar 04, 2019 03:19 PM|bruce (sqlwork.com)|LINK
Participant
1253 Points
932 Posts
Mar 05, 2019 05:26 AM|yogyogi|LINK
The API method needs you to provide your Username and Password for accessing it.
You have to find out how to send the credentials to the API i.e. either in through JSON, or through form or through http header.
Once you find out this then you can send the credentials to the API when making the API call.
Consuming ASP.NET Web API is the perfect article which you should reference here.
None
0 Points
11 Posts
Displaying External Content In MVC
Mar 04, 2019 11:37 AM|samirkarim|LINK
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.
?????
All-Star
57884 Points
15516 Posts
Re: Displaying External Content In MVC
Mar 04, 2019 03:19 PM|bruce (sqlwork.com)|LINK
Participant
1253 Points
932 Posts
Re: Displaying External Content In MVC
Mar 05, 2019 05:26 AM|yogyogi|LINK
The API method needs you to provide your Username and Password for accessing it.
You have to find out how to send the credentials to the API i.e. either in through JSON, or through form or through http header.
Once you find out this then you can send the credentials to the API when making the API call.
Consuming ASP.NET Web API is the perfect article which you should reference here.
♠ ASP.NET Core Tutorials → Start from the Beginning and become an Expert in 30 days time ♠