473,320 Members | 1,867 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.

UrlRewriting - how + where to do the redirect calculations

Hi All,

I'm doing UrlRewriting based on the model in Scott Mitchell's article "URL
Rewriting in ASP.NET".
http://msdn.microsoft.com/library/de...lrewriting.asp.

In this article the logic for rewriting URLs is contained in Regular
Expressions in the web.config file, like this:
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/(\d{4})/Default\.aspx</LookFor>
<SendTo>~/ShowBlogContent.aspx?year=$1</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>

What I like about this approach is that you can change the web.config file
using a text editor and these changes are reflected in the site *without*
having to recompile any dll's.

However (partly because my Regular Expression knowledge isn't that good) I'd
like to do some of the rewriting logic via some plain old C# functions - but
(and here's the tricky bit) still *without* having to recompile.

Can anyone suggest any ways this might be done?

TIA,

JON

Nov 22 '05 #1
8 1492
hi.
try storing the values in the DB. so you can modify them without having to
touch the web.config file. if you make any changes to the web.config file,
you may not have to recompile but the whole web application is being
restarted. so if you are using session objects and application objects, they
are being restarted as well. but making changes to the db will not affect
your application when it comes to server objects.

hope this helps.

"Jon Maz" wrote:
Hi All,

I'm doing UrlRewriting based on the model in Scott Mitchell's article "URL
Rewriting in ASP.NET".
http://msdn.microsoft.com/library/de...lrewriting.asp.

In this article the logic for rewriting URLs is contained in Regular
Expressions in the web.config file, like this:
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/(\d{4})/Default\.aspx</LookFor>
<SendTo>~/ShowBlogContent.aspx?year=$1</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>

What I like about this approach is that you can change the web.config file
using a text editor and these changes are reflected in the site *without*
having to recompile any dll's.

However (partly because my Regular Expression knowledge isn't that good) I'd
like to do some of the rewriting logic via some plain old C# functions - but
(and here's the tricky bit) still *without* having to recompile.

Can anyone suggest any ways this might be done?

TIA,

JON


Nov 22 '05 #2
hi.
try storing the values in the DB. so you can modify them without having to
touch the web.config file. if you make any changes to the web.config file,
you may not have to recompile but the whole web application is being
restarted. so if you are using session objects and application objects, they
are being restarted as well. but making changes to the db will not affect
your application when it comes to server objects.

hope this helps.

"Jon Maz" wrote:
Hi All,

I'm doing UrlRewriting based on the model in Scott Mitchell's article "URL
Rewriting in ASP.NET".
http://msdn.microsoft.com/library/de...lrewriting.asp.

In this article the logic for rewriting URLs is contained in Regular
Expressions in the web.config file, like this:
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/(\d{4})/Default\.aspx</LookFor>
<SendTo>~/ShowBlogContent.aspx?year=$1</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>

What I like about this approach is that you can change the web.config file
using a text editor and these changes are reflected in the site *without*
having to recompile any dll's.

However (partly because my Regular Expression knowledge isn't that good) I'd
like to do some of the rewriting logic via some plain old C# functions - but
(and here's the tricky bit) still *without* having to recompile.

Can anyone suggest any ways this might be done?

TIA,

JON


Nov 22 '05 #3
Hi,

Maybe I didn't explain myself well, but that isn't really what I'm after...
I'll try again!

When doing the UrlRewriting, there isn't always going to be a simple 1:1
correlation between a word/sequence of words in the original url and the
..aspx file the url needs to be redirected to. There may be some quite
complicated processing and validation involved.

It's reasonable to ask why I don't just stick this processing in some
classes/functions in a .cs file in amongst the urlRewriting classes... Now
I *could* do that, and in fact right now I don't have any other solution,
but these classes would (of course) be pre-compiled and thus, in my
production setup (shared hosting) a *real* pain to change, as this involves
downloading source files, compiling on local, re-uploading the updated dll's
bla bla bla.

I'm trying to actively minimise the amount of pre-compiled code in my app by
going for inline code instead of code-behind, and this is the spirit behind
my question here. What I'm looking for is a way of writing these
classes/functions that is not pre-compiled (in the same way inline code
pages are not pre-compiled), allowing me to edit these functions on the fly
and not have to recompile with every change...

Hope that makes more sense!

Thanks,

JON
Nov 22 '05 #4
Hi,

Maybe I didn't explain myself well, but that isn't really what I'm after...
I'll try again!

When doing the UrlRewriting, there isn't always going to be a simple 1:1
correlation between a word/sequence of words in the original url and the
..aspx file the url needs to be redirected to. There may be some quite
complicated processing and validation involved.

It's reasonable to ask why I don't just stick this processing in some
classes/functions in a .cs file in amongst the urlRewriting classes... Now
I *could* do that, and in fact right now I don't have any other solution,
but these classes would (of course) be pre-compiled and thus, in my
production setup (shared hosting) a *real* pain to change, as this involves
downloading source files, compiling on local, re-uploading the updated dll's
bla bla bla.

I'm trying to actively minimise the amount of pre-compiled code in my app by
going for inline code instead of code-behind, and this is the spirit behind
my question here. What I'm looking for is a way of writing these
classes/functions that is not pre-compiled (in the same way inline code
pages are not pre-compiled), allowing me to edit these functions on the fly
and not have to recompile with every change...

Hope that makes more sense!

Thanks,

JON
Nov 22 '05 #5
exactly..
the values that needs to be changed here are those for "lookfor" and "send
to"; now a class or a compiled function will always loop or do the same
thing, find a match of these two values. what im suggesting is store these
"lookfor" and "sendto" values in the db. they are just string after all. and
when you do regex, it looks for the absolute value of the regex pattern
(which means you can use a variable). and that variable value is the value
you stored from the db....

if still this doesnt work, maybe you can store the values in xml and use
classic asp to process this logic, in classic asp, you can edit and dump them
as you wish without worrying about compiling and stuff...
"Jon Maz" wrote:
Hi,

Maybe I didn't explain myself well, but that isn't really what I'm after...
I'll try again!

When doing the UrlRewriting, there isn't always going to be a simple 1:1
correlation between a word/sequence of words in the original url and the
..aspx file the url needs to be redirected to. There may be some quite
complicated processing and validation involved.

It's reasonable to ask why I don't just stick this processing in some
classes/functions in a .cs file in amongst the urlRewriting classes... Now
I *could* do that, and in fact right now I don't have any other solution,
but these classes would (of course) be pre-compiled and thus, in my
production setup (shared hosting) a *real* pain to change, as this involves
downloading source files, compiling on local, re-uploading the updated dll's
bla bla bla.

I'm trying to actively minimise the amount of pre-compiled code in my app by
going for inline code instead of code-behind, and this is the spirit behind
my question here. What I'm looking for is a way of writing these
classes/functions that is not pre-compiled (in the same way inline code
pages are not pre-compiled), allowing me to edit these functions on the fly
and not have to recompile with every change...

Hope that makes more sense!

Thanks,

JON

Nov 22 '05 #6
exactly..
the values that needs to be changed here are those for "lookfor" and "send
to"; now a class or a compiled function will always loop or do the same
thing, find a match of these two values. what im suggesting is store these
"lookfor" and "sendto" values in the db. they are just string after all. and
when you do regex, it looks for the absolute value of the regex pattern
(which means you can use a variable). and that variable value is the value
you stored from the db....

if still this doesnt work, maybe you can store the values in xml and use
classic asp to process this logic, in classic asp, you can edit and dump them
as you wish without worrying about compiling and stuff...
"Jon Maz" wrote:
Hi,

Maybe I didn't explain myself well, but that isn't really what I'm after...
I'll try again!

When doing the UrlRewriting, there isn't always going to be a simple 1:1
correlation between a word/sequence of words in the original url and the
..aspx file the url needs to be redirected to. There may be some quite
complicated processing and validation involved.

It's reasonable to ask why I don't just stick this processing in some
classes/functions in a .cs file in amongst the urlRewriting classes... Now
I *could* do that, and in fact right now I don't have any other solution,
but these classes would (of course) be pre-compiled and thus, in my
production setup (shared hosting) a *real* pain to change, as this involves
downloading source files, compiling on local, re-uploading the updated dll's
bla bla bla.

I'm trying to actively minimise the amount of pre-compiled code in my app by
going for inline code instead of code-behind, and this is the spirit behind
my question here. What I'm looking for is a way of writing these
classes/functions that is not pre-compiled (in the same way inline code
pages are not pre-compiled), allowing me to edit these functions on the fly
and not have to recompile with every change...

Hope that makes more sense!

Thanks,

JON

Nov 22 '05 #7
Hi Alan,

Mmm... Maybe you're right that a db could handle this if "lookfor" and
"sendto" were the only variables involved, but I'm facing processing like
(in pseudocode):

Check to see how many articleIDs (11-digit numerics) there are in
the url
if there's one, go to article.aspx
if there's more than one then go to special.aspx

or

if there's an articleType and an articleCategory but no
articleSubcategory (each of which may require a db lookup) in the
url then.....

Your idea of using classic asp sounded more promising, but unfortunately to
get my UrlRewriting to work as I wish I've had to push *all* requests
through the asp.net engine ie in IIS Application Mappings I've put a *
extension which maps to aspnet_isapi.dll. So basically I can't use classic
asp.

Back to square one?

Thanks for the help,

JON


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.794 / Virus Database: 538 - Release Date: 10/11/2004
Nov 22 '05 #8
Hi Alan,

Mmm... Maybe you're right that a db could handle this if "lookfor" and
"sendto" were the only variables involved, but I'm facing processing like
(in pseudocode):

Check to see how many articleIDs (11-digit numerics) there are in
the url
if there's one, go to article.aspx
if there's more than one then go to special.aspx

or

if there's an articleType and an articleCategory but no
articleSubcategory (each of which may require a db lookup) in the
url then.....

Your idea of using classic asp sounded more promising, but unfortunately to
get my UrlRewriting to work as I wish I've had to push *all* requests
through the asp.net engine ie in IIS Application Mappings I've put a *
extension which maps to aspnet_isapi.dll. So basically I can't use classic
asp.

Back to square one?

Thanks for the help,

JON


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.794 / Virus Database: 538 - Release Date: 10/11/2004
Nov 22 '05 #9

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

Similar topics

4
by: Jon Maz | last post by:
Hi All, I'm doing UrlRewriting based on the model in Scott Mitchell's article "URL Rewriting in ASP.NET"....
2
by: End Around | last post by:
I am creating a time-based art web site that will show a different html page depending on the client side local date. I also prefer that the top page doesn't literally redirect to, say 7.htm for...
11
by: lduperval | last post by:
Hi, I`m trying to do date calculations in three types of time zones: local, GMT and specified. The issue I am facing is that I need to be able to specify a date in the proper time zone, and I`m...
3
by: brian kaufmann | last post by:
Hi, I had sent this earlier, and would appreciate any suggestions on this. I need to make calculations for unemployment rate for three different data sources (A,B,C) for many countries and age...
3
by: John M | last post by:
Hi, I've been coming up against a failure of a report to display the result of a simple calculation. I have realised that this calculation cannot take place unless the field I am working on is...
0
by: SJM | last post by:
There is a database which has combo boxes to allow users to select values from pre-set lists of common specifications. The form allows users to enter values that are not in the dropdown lists....
4
by: darrel | last post by:
I'm building a site template that, hopefully, will be just one single ASPX page. There are 10 main districts (each getting a variation of the template), and I could easily pass that info via a...
6
by: Coleen | last post by:
Hi all :-) I need to redirect to multiple pages on click of a transmit button, without redisplaying each page. This redirection is to capture session variables that are created on each page and...
18
by: Jordan Glassman | last post by:
Trying to do something fairly routine... drop output into a file to graph, but the following command at the bash command line: ising output produces a blinking cursor, an empty file named...
9
Catalyst159
by: Catalyst159 | last post by:
I have a form which is used to calculate residential Floor Area Ratio (FAR). The form is structured into seven parts as follows: Part A: Maximum FAR and Floor Area: Part B: Gross Floor Area of...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
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...
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
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.