Hi,
I'm performing a UrlRewrite for my main category pages. Converting: www.mysite.com/Category.aspx?id=2 to www.mysite.com/Dogs
In order to do so I'm using Global.asax's Application_BeginRequest where I perform the following code(psuedocode):
protected void Application_BeginRequest(Object sender, EventArgs e)
{
if (IsCategoryUrl())
{
string CategoryName = ParseCategoryNameFromUrl(Request.Url);
string CategoryId = GetCategoryIdByNameFromDB( CategoryName );
Context.RewritePath("/Category.aspx?id=" + CategoryId);
}
}
My questions are:
- Is this the right way to perform Url Rewriting? (It's the first time i'm doing so).
- This code causes a read from DB on almost EVERY request, is there any way to cache it? The only technique I found for SQL Caching required a <%@ Page %> directive which isn't possible on the global.asax. Any other solution?
Thanks in advance.