Is there such a thing as strongly typed URLs?

P

Polaris431

In code, you can type the following:

this.Response.Redirect("~/index.aspx");

Is there anything in ASP.NET that you can use in place of strings when
referring to URLs? It would be nice to refer to URLs in a strongly
typed fashion. Something like:

this.Response.Redirect(URLs.Index_ASPX);

The point of this is that if a URL gets changed to a different
location or even renamed, the URL in a a Redirect (or for any other
object for that matter) would be automatically updated to refer to the
new name / location.

I doubt that this exists but it would be nice if it did.

Thanks
Polaris
 
S

Steve C. Orr [MCSD, MVP, CSM, ASP Insider]

I've seen a lot of people use constants/enums/structs for that kind of
thing.
They don't automatically update when the URL changes but at least they are
centrally defined so you only have one place to go to update a URL.
 
R

Rad [Visual C# MVP]

In code, you can type the following:

this.Response.Redirect("~/index.aspx");

Is there anything in ASP.NET that you can use in place of strings when
referring to URLs? It would be nice to refer to URLs in a strongly
typed fashion. Something like:

this.Response.Redirect(URLs.Index_ASPX);

The point of this is that if a URL gets changed to a different
location or even renamed, the URL in a a Redirect (or for any other
object for that matter) would be automatically updated to refer to the
new name / location.

I doubt that this exists but it would be nice if it did.

Thanks
Polaris

Take a look at PageMethods, recently moved here
http://www.codeplex.com/PageMethods
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top