Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

URL Rewrite Mapping question.

Posted on 2009-05-15
4
Medium Priority
?
1,367 Views
Last Modified: 2013-12-09
Hi,

I have a website written in .Net c# and we are on win2008 iis7.

Now IIS7 is great and it provides rewrite module. However I need help for automating my url rewrite. I have thousands of records in my database and i can not possibly create a rewrite rule for each.

I have 3 sections in the website Concerts, Sports, Art & Theatre

--------------------------------------------------------
Concert Category

The url structure:
www.domain.com/Music.aspx?eid=2e051e40-63d0-dd11-a62a-003048676ea7

Should rewrite as
http://www.yourticketmarket.com/concerts-tickets/melanie-tickets

As you can guess the eid query string gets the event details from the database and displays it on the page. I can easily create a rule to replace this id with melani-tickets.
----------------------------------------------------------

Theatre Category

The url structure is the same but the file is different.
http://www.domain.com/ArtAndTheater.aspx?eid=6bbc1d2f-1edb-dd11-8af8-003048676ea7

Should rewrite as
http://www.yourticketmarket.com/theatre-tickets/oliver-tickets

-----------------------------------------------------------

so on...

The problem is how can I automatically create url rewrite for each record in the database? For example how can I get the name of the event to use in the structure above?

Many thanks for your comments in advance!




0
Comment
Question by:scava
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 18

Expert Comment

by:Hube02
ID: 24396519
Okay, first, let me say that I'm no expert with rewriting on IIS7 or C#, but my comments are more to the point of theory than actual coding.

It probably is not a good idea to try to generate a different unique rewrite rule for every posibility in the database, this is due to the fact that this list would have to be regenerated every time the is a database changes. Instead, I would look for a way to create several generic rewrites that would encompass all the possibilities.

So lets take a single example from your above examples:

***************************
The url structure:
www.domain.com/Music.aspx?eid=2e051e40-63d0-dd11-a62a-003048676ea7

Should rewrite as
http://www.yourticketmarket.com/concerts-tickets/melanie-tickets
***************************

What I would do here is have a rule that rewrites:

/concerts-tickets/melanie

to:

/Music.aspx?artist=melanie

I'm just using artist=melanie for an example. This would also need to be something unique in your database.

Now, when Music.aspx is called, instead of looking up the eid value, you would look up the artist value to get the eid value and then process your page as normal. What this means is that you only need 3 rewrite rules rather than the potential thousands of rules you would need if you have a very large database of information.

What this means, as mentioned above, each event name would need to be unique in some way so that you can look up the event by the event name, rather than by the eid value. So a change to the way the database functions. In this case I might alter the rule a bit. For instance, each event may not have a unique name, but each event is likely associated with a specific date, so the event name combined with the event date would give you a unique combination that you can look up. This means that instead of the URLs you propose, you would also need to include the date somehow.

for instance:
http://www.yourticketmarket.com/theatre-tickets/oliver-tickets/20090515
0
 

Author Comment

by:scava
ID: 24396890
Thanks,

for this we will have to make considerable changes in the code. The application is massive and we can only work with querystring eid.

Events will be entered to the system only once and each will have its own unique number (eID) therefore I need a solution such as "URL Mapping", or is there another way?

Any examples would be appreciated on .NET CSharp if applicable.

Many thanks
 




0
 
LVL 23

Accepted Solution

by:
Tony McCreath earned 1500 total points
ID: 24402073
The other way is to create a .Net HttpModule to do rewriting for you.

As its in your application you can access the database to gather the extra data you need.

HttpModules can intercept requests and use RewritePath to change where the request ends up.

To have it handle folders as well you will need to configure the application so that it has a wildcard mapping to the correct aspnet_isapi.dll (uncheck 'check if file exists').

0
 

Author Closing Comment

by:scava
ID: 31581936
Thanks. This is not specific but it has given us an answer on the path we should take.
0

Featured Post

Put Machine Learning to Work--Protect Your Clients

Machine learning means Smarter Cybersecurity™ Solutions.
As technology continues to advance, managing and analyzing massive data sets just can’t be accomplished by humans alone. It requires huge amounts of memory and storage, as well as the high-speed power of the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question