Is there such a thing as strongly typed URLs?

  • Thread starter Thread starter Polaris431
  • Start date Start date
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
 
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.
 
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
 
Back
Top