473,405 Members | 2,262 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Verifying a URL

Hi,

I have situation where I want to use a stylesheet stored
in one of two possible urls. Basically I need to say if
the first url doesn't exist, use the second url.

I can do this by creating a WebRequest and intercepting
the exception raised by the GetResponse if the first url
doesn't exisit, but this feels like a hack to me and I was
hoping there would be some simple way (similar to
File.Exists) to check whether a url refered to a file that
was actually there?

Any help would be appreciated.

Thanks.
Nov 17 '05 #1
3 1845
Actually, before I finished reading your post I thought about telling you to
use the WebRequest class. I think you are on the right track, but you might
want to consider caching the URL so that it's not done for every request to
your web form.

Mario

"julian" <ju**********@strategicthought.com> wrote in message
news:08****************************@phx.gbl...
Hi,

I have situation where I want to use a stylesheet stored
in one of two possible urls. Basically I need to say if
the first url doesn't exist, use the second url.

I can do this by creating a WebRequest and intercepting
the exception raised by the GetResponse if the first url
doesn't exisit, but this feels like a hack to me and I was
hoping there would be some simple way (similar to
File.Exists) to check whether a url refered to a file that
was actually there?

Any help would be appreciated.

Thanks.

Nov 17 '05 #2
Actually, that's why structured exception handling was created. You catch an
exception to recover from it. That's how your applications come become
"smarter." They learn from their mistakes, he he.

Mario

"julian" <ju**********@strategicthought.com> wrote in message
news:00****************************@phx.gbl...
Thanks for the responses. I guess I will leave it the way
it is then - it certainly works. I just feel a bit
guilty / lazy to be using Exceptions to handle an expected
condition (i.e. not an error).

-----Original Message-----
Hi,

I have situation where I want to use a stylesheet stored
in one of two possible urls. Basically I need to say if
the first url doesn't exist, use the second url.

I can do this by creating a WebRequest and intercepting
the exception raised by the GetResponse if the first url
doesn't exisit, but this feels like a hack to me and I

was
hoping there would be some simple way (similar to
File.Exists) to check whether a url refered to a file

that
was actually there?

Any help would be appreciated.

Thanks.
.

Nov 17 '05 #3
Thanks for the responses. I guess I will leave it the way
it is then - it certainly works. I just feel a bit
guilty / lazy to be using Exceptions to handle an expected
condition (i.e. not an error).

-----Original Message-----
Hi,

I have situation where I want to use a stylesheet stored
in one of two possible urls. Basically I need to say if
the first url doesn't exist, use the second url.

I can do this by creating a WebRequest and intercepting
the exception raised by the GetResponse if the first url
doesn't exisit, but this feels like a hack to me and I washoping there would be some simple way (similar to
File.Exists) to check whether a url refered to a file thatwas actually there?

Any help would be appreciated.

Thanks.
.

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Michael | last post by:
I'd like to write a program to verify the consistency between various database replicas in our environment. The rules are as follows: - I'm given two servers, each with a database - I don't...
1
by: Marcus | last post by:
Hi What is a proper way of verifying that a mysql write was successfull, and to retry if it wasnt? In my perl script I add records through: my $dbh=DBI->connect($dsn, $db_user_name,...
10
by: Chris Sharman | last post by:
I'm doing a rough validation of an email address client-side (using js), but it's not enough - our customer service people are apparently incapable of typing in an email address without error - we...
4
by: HD | last post by:
Hi, I was wondering if there is a way of verifying information that is in the registry of the user's computer??? Or is there a way of checking if a file is on the c:\ of the user's computer?? I...
9
by: Carter Smith | last post by:
http://www.icarusindie.com/wiki/index.php/Server-Side_Javascript_Check Sample source included This method requires that your pages are PHP enabled and you have mySQL. Although I suppose you...
4
by: Reinhold Schalk | last post by:
Hello, somewhere i've read that using strong names does assure two things: 1. Assure that the content of the assembly is not modified (that's ok in my opinion) 2. Assure that the assembly is...
6
by: John | last post by:
Hi I have several web forms that require users verification by entering a code before they are allowed in. I have created a separate web form for entering and verifying user code. How do I...
5
by: Geisler, Jim | last post by:
So, as far as I know, PostgreSQL does not have any way of verifying the loss of referential integrity. Are there any recommended methods or utilities for checking referential integrity in a...
1
by: koch.henning | last post by:
Hello, I have some sort of problem with verifying the contents of my xml-document. I have a xml-scheme like this... <xs:complexType name="abcType"> <xs:sequence> <xs:element name="elementA"...
1
by: foothills bhc | last post by:
I have a problem with verifying content of controls on a form before closing the form or moving to the next form "record" (i.e., when moving to the next row of my form's record source). HERE'S THE...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.