The remote server returned an error: (401) Unauthorized.

S

sirumalla

These posting i have seen in so many sites but none of them solved the
problem. Iam trying to fix this problem past 2 days but iam not able
to do so. I doubt whether iam missing any peice of code

I am trying to logon to remote server thru my code. when i paste the
link in web browser it is working correctly but when iam trying to
execute thru my code it is giving me problem saying ur Unauthorized.

Here is my code:

PQRS.PDS ws = new PQRS.PDS();

sURL = ConfigurationSettings.AppSettings["PQRS"].Trim() +
"/LgnPSAu.asp?un=a1d2f3ggkkkkk&pwd=";

finally iam building the url with user and pwd...if i take the url and
try in webbrowser, it is working fine and iam getting the xmlreply
reply back with error code as zero.

The result is like
<?xml version="1.0" ?>
- <Reply><HRESULT>0</HRESULT>
- <Cookie>
- <![CDATA[ svc={XXXXXXXXXXXX}&session={YYYYYYY}&prxy={ZZZZ}&org=ABC
]]></Cookie></Reply>

after getting the URL my code runs..

HttpWebRequest myreq = (HttpWebRequest)WebRequest.Create(sURL);
CookieContainer concookie = new CookieContainer();
ws.Credentials = CredentialCache.DefaultCredentials;
myreq.CookieContainer = concookie;
myreq.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse myres = (HttpWebResponse)myreq.GetResponse();

Here iam getting the problem with
"The remote server returned an error: (401) Unauthorized."

I tried with different options as i got the info based on my search..
changed my IIS settings.. still the problem is persisting..I strongly
believe this is problem with IIS or networkconnections...;It will be
Helpfull if anyone can assist me;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top