This question touches upon problems that are so common that it is difficult to answer considering all possibilities. The point you seem to be confusing in your post is that the PInvoke method PathIsURL (or its related method, IsValidUrl) both only test the supplied string for conformance to URI format rules. It does not test the actual existence of the URL on the internet by initiating a request to the internet resource. Therefore, the question of a status code using those functions is moot.
There are multiple levels of validation you can apply to a Url string. Which ones you choose depends upon the degree of validation you require : 1. Validate it based on a reasonably restrictive Regex. If successful, use method #2. 2. Validate it based on the inbuilt logic of the Uri class. The constructor itself will throw a UriFormatException if your Url is in incorrect format. Move to method #3 or #4. 3. Validate the existence of the host name using one of the methods of the Dns class. (Or use method #4) 4. Use the WebClient or HttpWebRequest objects to create a request to the supplied Url. If you use a HEAD request, it will be sufficient to test the actual existence of the Url on the internet. This should also return the Status code you need. On Oct 21, 11:49 am, Muhammad Arif <[email protected]> wrote: > Hello all : > I am checking URL validation for this purpose i have > used window api PathIsURL but its return type is long.. from which i > can't know that what is the HttpStatusCode ... > > i need httpstatus code.. as i have already get true and false from > it.. but i need httpstatuscode from it// > so my question is that how can i get httpStatusCode from PathIsURL > > Note: > I have already used HttpRequest and HttpResponse but i want > to do it through windows api..
