Thanks Rick, Thanks Martin,
I did have the windows authentication enabled for the root directory, still
no luck.
I got my credentials as suggested by Martin:
NetworkCredential nc = (NetworkCredential)
CredentialCache.DefaultCredentials;
It works perfectly.
Once again guys thanks a lot, you have solved a major problem for me. Your
efforts are much appreciated.
With Regards
Deepak
"Martin Dechev" <de*******@hotmail.com> wrote in message
news:el****************@TK2MSFTNGP10.phx.gbl...
Hi, Deepak,
You should use:
NetworkCredential nc = System.Net.CredentialCache.DefaultCredentials;
Have a look at:
http://support.microsoft.com/?kbid=811318
Hope this helps
Martin
"Deepak" <le********@hotmail.com> wrote in message
news:ur**************@TK2MSFTNGP10.phx.gbl... Hi Experts,
I have a page in my inetpub\wwwroot called testpage.asp. I have removed
anonymous access to this page and have checked windows integrated
security. Now when I try to access this page from code I get a 401 error. Why is
this? I am able to acces the page from IE without any problem. what can do to
get around this problem.
here's my code :
try
{
WebClient wc = new WebClient();
NameValueCollection nvc = new NameValueCollection();
string uri;
uri = "http://localhost/testpage.asp";
NetworkCredential nc = new NetworkCredential("raj","");
wc.UploadValues(uri,nvc);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
--
With Regards,
Deepak