I am making a web request to a site & all is working fine. But today i found that the site url isnt working. Site is unavailable due to some reasons. So then in my code i am getting error of "Unable to connect to remote server". My code is as follows.
private WebRequest _request;
_request = WebRequest.Create(uri[j]); // uri[j] is an array containing site url
_request.Method = "POST";
_request.ContentType = "application/x-www-form-urlencoded";
_request.ContentLength = buffer.Length;
PostData = _request.GetRequestStream(); <---- gives error
PostData.Write(buffer, 0, buffer.Length);
How can i catch this exception? Is there some way to catch such exception??? Thnx in advance..
I want to add Hit counter to my site. I found few ways to do it:
1. Free hit counters - Problem is it adds site's links/signature.
2. Hit counter using file based storage - File can be crashed when lots of concurrent hits.
3. Database hit counter - Slowdowns the page load.
What is best way to implement it. It's my intranet company site where I need to do it.
Well, the header you used was ridiculous, the code sucks in all sorts of ways - how about telling us what the code is supposed to do. I doubt it's even ASP.NET code, I've never seen anyone silly enough to do a postback on a key press.