Currently I have the following code that is run on ButtonClick:
Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenWindow",
"window.open('" + DocumentData.Tables[0].Rows[0]["WebAddress"].ToString()
+ "','_blank');", true);
It opens popup window with given link from DataBase (usually it is a link to document or image or video).
But I need to modify code a bit and I do not know which methods should I use:
1) I need to check if url really exists (if URL is responsive) and if not do not open popup, but show some message. Here I do not know how to check if Url exists? For example, if url is something like http://www.thesitedoesntexists.com then Do not load popup.
2) If url is in format http://www.yahoo.com instead of http://www.yahoo.com or https://someurl.com then above doesn’t work.
If my web application is www.myapplication.com then in above scenario system opens url www.myapplication.com/www.yahoo.com instead of www.yahoo.com. How to deal with it? It could be somehow related with question #1. And this is the main problem.
The following code (untested) should accomplish these tasks:
Button click handler code:
and define the following URL check method in your class:
I give full credit to the UrlExists method to:
http://paigecsharp.blogspot.ca/2011/01/verify-url-exists.html