I have a one page ASP.NET 4.0 C# script running. In debug mode my script works just fine but when I publish it, it seems like it is not sending the credentials when making the WebRequest. The following is the code I am using, I have tried a bunch of things but I keep getting a 401 Unauthorized when I am using my published version of the script. BTW I am using IIS 7
WebRequest fwRequest = HttpWebRequest.Create(fwURL);
fwRe开发者_开发知识库quest.UseDefaultCredentials = true;
//fwRequest.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse myHttpWebResponse = (HttpWebResponse)fwRequest.GetResponse();
While debugging, your project use your credentials, but when you publish it it will use the credentials of ASP.NET user, or the credentials set in IIS configuration. So no, you can not pass credentials of your client to another web service/appliaction unless you convince him/her to pass username-password to your application (Except that both web apps are on the same machine).
精彩评论