[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

HttpModule not working to mimic subdirectories, what to do then ?

Posted on 2005-04-23
6
Medium Priority
?
334 Views
Last Modified: 2010-07-27
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.
0
Comment
Question by:fischermx
  • 4
  • 2
6 Comments
 
LVL 6

Expert Comment

by:sansoftura
ID: 13852357
Have you configured the IIS configuraion - deselect "Verify that file exists" for aspnet_isapi.dll?

http://msdn.microsoft.com/canada/btl/jan_winner1.asp
0
 
LVL 1

Author Comment

by:fischermx
ID: 13852479
> Have you configured the IIS configuraion - deselect "Verify that file exists" for aspnet_isapi.dll?
I don't know which "wilcard" would match a directory entry/call.
I added a dot ".", because if I put a slash "/", the ok button gets disabled, like if it is invalid.


I think I'll change my question : Is that supposed to work ?
I mean, using a custom HttpModule, can I use it in a way to fake a directory (i.e. not a file) ?
I have to ask this, because in all samples I've seen, they always manage to use a file, "anything.aspx", not a directory "/anything/".

0
 
LVL 1

Author Comment

by:fischermx
ID: 13852492
Both the "*" and the "/" are not accepted as "extension" in the IIS configuration.

The link shown, has an example again using a file, with extension, not a directoy.
I guess, it should be possible somehow, see dmoz.org, they don't have real subdirectories, they are doing something similar, but hey, they are using PHP or Perl.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 6

Accepted Solution

by:
sansoftura earned 2000 total points
ID: 13853137
Here is an article in MSDN
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/ASPNet-OneSiteManyFaces.asp. It has lots of stuff but also includes request mapping.
0
 
LVL 1

Author Comment

by:fischermx
ID: 13853905
I saw that articles and I've seen other similars. At the end, they mentioned about the "problem" of showing a directory. Their solution is to actually create the directory and put a default.aspx, even empty page, there. I don't like that solution at all, what I want is to avoid having physical files, that's why we're doing dinamic pages.
As I told, I've seen solutions on *nix platforms doing this, I still thinking would be a tweak to make this in a more elegant and easy way.
0
 
LVL 1

Author Comment

by:fischermx
ID: 14031951
Any other input on this ?
I can't believe this can't be done with IIS/Asp.Net, the Apache guys must be laughing at me (us microsoft's users).
There are sites that have structures like this :

http://www.mydomain.com/dir1/
http://www.mydomain.com/dir2/
http://www.mydomain.com/dir1/subdir1/
http://www.mydomain.com/dir1/subdir2/

They never show an extension, this is what I am trying to achieve.
I already have like this :
http://www.mydomain.com/dir1/default.aspx
http://www.mydomain.com/dir1/subdir1/default.aspx

But that's not what I want, I want to take ride of the default page.

Thanks in advance.


0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

834 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