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

RewritePath

Hi everybody,
I'm developing a simple web site for a friend of mine and I need an help for
the folloeing situation: I am planning to map friendly page name (like
'/faq.aspx') to more complicated ones (like '/displaypage.aspx?id=1'). I've
done an internet search and I found that I can achieve this using httpModule.
My first attempt was to using RwritePath in the BeginRequest event handler,
retrieving the id associated to the friendly page and rewrite the path (using
RewritePath) with the "complicated" one. Everything worked fine.
Then I thought to optimize the site in order to reduce the number of
connection to the database which stores the link between friendly pages and
ids: to do this I thought to put the Dictionary containing the associations
into the Session object in order to avoid connecting to the db after the
first load.
To do this I moved all the code from the BeginRequest handler to the
PostAcquireRequestState one. Everything seems to work fine but the
RewritePath as no effect.
Here's the bit of code:

private void context_PostAcquireRequestState(object sender, System.EventArgs
e)
{
String RequestedUrl =
HttpContext.Current.Request.Path.ToLowerInvariant( );

if (System.IO.Path.GetExtension(RequestedUrl)==".aspx ")
{
String ButtonKey =
RequestedUrl.Substring(RequestedUrl.LastIndexOf("/") + 1);
if (HttpContext.Current.Session["MenubarButtonsList"] == null)
{
HttpContext.Current.Session["MenubarButtonsList"] =
UserComponent.GetMenubarButtonsList(HttpContext.Cu rrent);
}
MenubarButtonsList ButtonsList =
(MenubarButtonsList)HttpContext.Current.Session["MenubarButtonsList"];

if (ButtonsList.ContainsKey(ButtonKey))
{
MenubarButton ReqButton = ButtonsList[ButtonKey];
if (ReqButton.RewritePath)
{
System.Text.StringBuilder NewUrl = new
System.Text.StringBuilder(HttpContext.Current.Requ est.ApplicationPath);
NewUrl.Append("/PageDisplayer.aspx?id=");
NewUrl.Append(ReqButton.Id);
HttpContext.Current.RewritePath(NewUrl.ToString()) ;
}
}
}
}
Any idea??
Thanks.

Massimo Necchi
Nov 9 '06 #1
0 959

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

Similar topics

0
by: Matt Howeson | last post by:
Some time ago I posted a request for help with a problem I was having sometime ago whereby a 404 error would result if any access to the Querystring had been made before the Context.Rewritepath is...
2
by: Corey O'Mara | last post by:
Hello all, I'd like to have personalized URL's in my application. For example, http://mydomain.com/sites/page.aspx should be accessible via http://mydomain.com/sites/username/page.aspx. I'd like...
8
by: Jiho Han | last post by:
Can someone explain in layman's term, what HttpContext.RewritePath does? SDK doc explanation is kind of scant. Does it only affect the request processing for the duration of the processing(meaning...
1
by: Oytun YILMAZ | last post by:
Hi I thing I have found a critical bug about ASP.NET ReWritePath Function Here are the steps to reproduce: I have a solution with this items: "MasterPageWithoutUserControl.aspx"...
15
by: James Higgs | last post by:
For a long time, our product has had a "vanity URLs" feature where nice URLs are mapped to ASPX files in an IHttpModule implementation, using HttpContext.RewritePath(). This has worked beautifully...
3
by: asanford | last post by:
I want to create an ASP.NET web application that receives a form POST message, inspects the data, and reroutes the request to one of many different servers. I wrote an IHttpModule which...
0
by: cpnet | last post by:
I was playing around with Beta 2 of VS2005, .NET 2.0, and built an IHttpModule do allow me to have nice URL's in my web app. It was working great. I had a URL like: ...
1
by: Massimo Necchi | last post by:
Hi everybody, I'm developing a simple web site for a friend of mine and I need an help for the folloeing situation: I am planning to map friendly page name (like '/faq.aspx') to more complicated...
1
by: Keef | last post by:
Hiya... just wondering if anyone else has come across this problem, and if there is a solution... i'm writing a reasonably simple IHttpModule to rewrite URLs ... in the BeginRequest event i...
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
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.