By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,011 Members | 1,000 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,011 IT Pros & Developers. It's quick & easy.

Is there a compile-time checked way of redirecting to a page?

P: n/a
Redirecting from page to page within a web project is pretty easy. However,
all Redirect methods take strings as arguments, as if you mistype the string,
you don't find out until run time that you are redirecting to somewhere that
doesn't exist.

Worse, if you do type it correctly, but then later the page name changes or
the page moves, you still won't find out until run time.

I have a framework that solves this problem and guarantees, at compile time,
that all redirect attempts to other pages in the web project are valid. I
like it very much. Unfortunately, ASP 2.0 trods all over the solution in a
number of ways and my sites don't even compile in the new framework. So,
before I try to cram my solution (very uncomfortably) into ASP 2.0, I'd like
to know if there is any other well-known solution to this problem.

Thank you.

Greg Smalter
Nov 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
No. How could there be? You could be redirecting to absolutely any site any
site on the internet. How could the compiler know which addresses are valid
and which are not.

"Greg Smalter" <Gr*********@discussions.microsoft.com> wrote in message
news:96**********************************@microsof t.com...
Redirecting from page to page within a web project is pretty easy.
However,
all Redirect methods take strings as arguments, as if you mistype the
string,
you don't find out until run time that you are redirecting to somewhere
that
doesn't exist.

Worse, if you do type it correctly, but then later the page name changes
or
the page moves, you still won't find out until run time.

I have a framework that solves this problem and guarantees, at compile
time,
that all redirect attempts to other pages in the web project are valid. I
like it very much. Unfortunately, ASP 2.0 trods all over the solution in
a
number of ways and my sites don't even compile in the new framework. So,
before I try to cram my solution (very uncomfortably) into ASP 2.0, I'd
like
to know if there is any other well-known solution to this problem.

Thank you.

Greg Smalter

Nov 19 '05 #2

P: n/a
There is. Obviously there have to be constraints, and the one I put forth is
that it is to another page within the same web project.

"Marina" wrote:
No. How could there be? You could be redirecting to absolutely any site any
site on the internet. How could the compiler know which addresses are valid
and which are not.

"Greg Smalter" <Gr*********@discussions.microsoft.com> wrote in message
news:96**********************************@microsof t.com...
Redirecting from page to page within a web project is pretty easy.
However,
all Redirect methods take strings as arguments, as if you mistype the
string,
you don't find out until run time that you are redirecting to somewhere
that
doesn't exist.

Worse, if you do type it correctly, but then later the page name changes
or
the page moves, you still won't find out until run time.

I have a framework that solves this problem and guarantees, at compile
time,
that all redirect attempts to other pages in the web project are valid. I
like it very much. Unfortunately, ASP 2.0 trods all over the solution in
a
number of ways and my sites don't even compile in the new framework. So,
before I try to cram my solution (very uncomfortably) into ASP 2.0, I'd
like
to know if there is any other well-known solution to this problem.

Thank you.

Greg Smalter


Nov 19 '05 #3

P: n/a
I suppose they could have written something like that, but I think in most
cases it is not all that useful. A spelling mistake like this isn't all that
common, and is usually caught early on if it happens (this is pretty rare).
At least in my experience and from the experiences I've seen with others.

You said you already wrote your own solution - why does 2.0 prevent you from
using it?

"Greg Smalter" <Gr*********@discussions.microsoft.com> wrote in message
news:0C**********************************@microsof t.com...
There is. Obviously there have to be constraints, and the one I put forth
is
that it is to another page within the same web project.

"Marina" wrote:
No. How could there be? You could be redirecting to absolutely any site
any
site on the internet. How could the compiler know which addresses are
valid
and which are not.

"Greg Smalter" <Gr*********@discussions.microsoft.com> wrote in message
news:96**********************************@microsof t.com...
> Redirecting from page to page within a web project is pretty easy.
> However,
> all Redirect methods take strings as arguments, as if you mistype the
> string,
> you don't find out until run time that you are redirecting to somewhere
> that
> doesn't exist.
>
> Worse, if you do type it correctly, but then later the page name
> changes
> or
> the page moves, you still won't find out until run time.
>
> I have a framework that solves this problem and guarantees, at compile
> time,
> that all redirect attempts to other pages in the web project are valid.
> I
> like it very much. Unfortunately, ASP 2.0 trods all over the solution
> in
> a
> number of ways and my sites don't even compile in the new framework.
> So,
> before I try to cram my solution (very uncomfortably) into ASP 2.0, I'd
> like
> to know if there is any other well-known solution to this problem.
>
> Thank you.
>
> Greg Smalter


Nov 19 '05 #4

P: n/a
I like to keep a list of my pages in a static class somewhere so that
this does not happen.

public abstract class Pages
{
public const string UserManage = "/Applications/UserManage.aspx";
public const string UserEdit = "/Applications/UserEdit.aspx";
public const string UserDelete = "/Applications/UserDelete.aspx";
public const string Index = "/Index.html";
}
Response.Redirect(Pages.UserManage, true);
This way, all potential typos are sitting next to each other in a
single file. If you refer to a page by the wrong name anywhere else,
it's a compile-time error.

Good luck!

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.