473,320 Members | 1,831 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,320 software developers and data experts.

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

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
4 1469
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: janeaustine50 | last post by:
Python's InteractiveInterpreter uses the built-in compile function. According to the ref. manual, it doesn't seem to concern about the encoding of the source string. When I hand in an unicode...
1
by: Mario T. Lanza | last post by:
I am working with Visual Studio. The solution I am developing is composed of about 8 separate projects. Some of these projects represent different tiers in the N-tiered architecture (data,...
4
by: frankg | last post by:
When I compile this file ------------------------------------------------------ #include <stdarg.h> template <class Any> void var_arg_func(int dimension_count, ...) { int dimensions;...
0
by: Jordan Willms | last post by:
My xsl stylesheet is as simple as follows: <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet xmlns:ims="http://www.imsglobal.org/xsd/imsmd_v1p2"...
12
by: jrefactors | last post by:
If the C programs have UNIX system calls such as fork(), alarm(), etc.., we should call it UNIX programs, not traditional C programs? We couldn't compile the programs with system calls using VC++...
2
by: Tony Johansson | last post by:
Hello! I get compile error when compiling using the command javac from the command terminal window(CMD). I have just two classes which are called HelloWorld.java and Slask.java. I have both...
4
by: tony | last post by:
Hello! My question is about calling this method CollectData below but I get a compile error that I shouldn't have because the type parameter is correct. The compile error is the following:...
3
by: NvrBst | last post by:
Right now I have C99 code in .c extensions. I compile it in VSC++ and it complains about a lot of errors. I change the extensions to .cpp and compile in VSC++ and it succeeds. Is there a way...
2
by: Andrus | last post by:
I need compile in-memory assembly which references to other in-memory assembly. Compiling second assembly fails with error Line: 0 - Metadata file 'eed7li9m, Version=0.0.0.0, Culture=neutral,...
6
by: Ed Leafe | last post by:
I've noticed an odd behavior with compile() and code that does not contain a trailing newline: if the last line is a comment inside of any block, a syntax error is thrown, but if the last line is a...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.