C
craigkenisston
Hi,
I'm writing an HttpModule in order to replace the parameters in the
aspx pages to look like subdirectories.
i.e. instead of having :
myexample.com/default.aspx?category=cat1&subcat=cat2
I want to have :
myexample.com/cat1/cat2/
While I was testing the functionality of HttpModule I was redirecting
from an ".aspx" file and it all was working fine.
Now that I switched to the real functionality, it just don't hit the
code.
I mean, the call to "myexample.com/cat1/cat2/" does not fire the
application request in my HttpModule.
Here is my code :
private void Application_BeginRequest(Object source,
EventArgs e)
{
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
string myPath = context.Request.
ServerVariables["PATH_INFO"];
string[] strs = ExtractParams(myPath);
string vendor="";
string category="";
if (strs.Length == 2)
{
vendor = strs[0];
category = strs[1];
context.RewritePath("~/default.aspx?
vendor="+vendor+"&category"+category);
}
}
Now, if I put a break in the first line I see that the code is not even
hit when I have something like "myexample.com/cat1/cat2/". It was
working if I have "myexample.com/cat1.aspx".
I guess I need to configure something, somewhere to call this code when
calling an URL with directories.
Thanks in advance.
I'm writing an HttpModule in order to replace the parameters in the
aspx pages to look like subdirectories.
i.e. instead of having :
myexample.com/default.aspx?category=cat1&subcat=cat2
I want to have :
myexample.com/cat1/cat2/
While I was testing the functionality of HttpModule I was redirecting
from an ".aspx" file and it all was working fine.
Now that I switched to the real functionality, it just don't hit the
code.
I mean, the call to "myexample.com/cat1/cat2/" does not fire the
application request in my HttpModule.
Here is my code :
private void Application_BeginRequest(Object source,
EventArgs e)
{
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
string myPath = context.Request.
ServerVariables["PATH_INFO"];
string[] strs = ExtractParams(myPath);
string vendor="";
string category="";
if (strs.Length == 2)
{
vendor = strs[0];
category = strs[1];
context.RewritePath("~/default.aspx?
vendor="+vendor+"&category"+category);
}
}
Now, if I put a break in the first line I see that the code is not even
hit when I have something like "myexample.com/cat1/cat2/". It was
working if I have "myexample.com/cat1.aspx".
I guess I need to configure something, somewhere to call this code when
calling an URL with directories.
Thanks in advance.