We have an application where a user will link a image to application. Sometime a user tries to associate a image which is from their own intranet and not on a open url. To handle such situation I tried to use response code from server which can be useful to handle such situation. I tried with a sample program but it throws exception and nothing is achieved. Is there any way around to get the response code from server even if a invalid URL is provided or know the reason exactly what was the problem.
My sample code to test this functionality is below :
Let me just point out that if the user provides a URL which does not connect to any server, it is unreasonable to expect to get a response code. That's because the response code is what the server sends as part of its response.
Joined: Jun 15, 2009
Thanks Paul. I will be using the exception type to recognize if a URL is invalid and display the appropriate error message to the user.