The problem is in "DefaultCredentials" which is empty.
google results did not give a effective solution.
Here is what i am trying
1. My System is connected to active directory
2. Enter username, password and domain to login in the system
3. Create a new website using vs2008
4. Create a page which contains a textbox which accepts the Url.
5. i am passing the url to the above function.
6. added impersonate in the web.config and directory property also
7. It returns an exception
but the same url if i paste in a browser -> it asks for username
and password. i am able to see the page
I have googled but the solution is not understandable or no answers for this question. Could any one help with a simple solution.
GaneshGdrBlr
Member
5 Points
4 Posts
DefaultCredentials problem
Aug 19, 2011 08:39 AM|LINK
Hi,
Below is the code to chek if a url is valid or not
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
request.PreAuthenticate = true;
request.Method = "HEAD";
request.Credentials = CredentialCache.DefaultCredentials;
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
return (response.StatusCode == HttpStatusCode.OK);
The problem is in "DefaultCredentials" which is empty.
google results did not give a effective solution.
Here is what i am trying
1. My System is connected to active directory
2. Enter username, password and domain to login in the system
3. Create a new website using vs2008
4. Create a page which contains a textbox which accepts the Url.
5. i am passing the url to the above function.
6. added impersonate in the web.config and directory property also
7. It returns an exception
but the same url if i paste in a browser -> it asks for username
and password. i am able to see the page
I have googled but the solution is not understandable or no answers for this question. Could any one help with a simple solution.
Thanks,
Jai
gww
Contributor
2143 Points
458 Posts
Re: DefaultCredentials problem
Aug 22, 2011 10:10 PM|LINK
What is the full text of the exception you get?
I would start by doing a response.write of the url being passed to the function and see what it looks like. You may need to url encode the url.