简体   繁体   中英

Does ASP .NET c# HttpWebRequest support HTTPS Authentication via username:password@www.website.com?

As the title says,

Does ASP .NET c# HttpWebRequest support HTTPS Authentication via username:password@www.website.com?

Almost everything I find regarding authentication appends the username and password after the website. Will using System.Net.HttpRequest work with username and password before the website?

[EDIT]

Let me explain the scenario, this is for an application that I am developing that makes a HTTP POST to a website. We are already using HTTPS, and the website server has my IP whielisted. At the request of someone from the 'website', they want to use the username:password@www.website.com in addition for authentication.

Adding credentials on the url never worked for me. This is how I'm currently doing it:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(apiUrl);
System.Net.CredentialCache credentialCache = new System.Net.CredentialCache();
credentialCache.Add(
    new System.Uri(apiUrl),
    "Basic",
    new System.Net.NetworkCredential(basicAuthUserName, basicAuthPassword)
);

request.PreAuthenticate = true;
request.Credentials = credentialCache;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM