locked
Rewriting URLs RRS feed

  • Question

  • User-1359823220 posted
    Im writing a handler that examines a URL and rewrites it if applicaple. Ive written the handler and it works fine when ever i request an url e.g. http://www.domain.com/test.aspx because in the web.config file I set the path where I add a ver I put into the path *.aspx like this <add verb="*" path="*.aspx". However I dont want to use an aspx extension. Rather I would like to be able to do http://www.domain.com/test (immitate a virtual directory) and then rewrite the URL. Ive tryied everything but nothing seems to work. Ive tryed changeing the path but that does not solve my problems. Any idea how I can achieve this.
    Tuesday, April 27, 2004 3:15 PM

All replies

  • User-1645088262 posted
    You need to setup wildcard application mapping in IIS (ie. map * to the ASP.NET dll)
    Tuesday, April 27, 2004 5:18 PM
  • User-1391363652 posted
    When you hit a folder IIS doesn't even pass the request to the Http pipeline and if the folder doesn't exist you get a 404. One guy posted an interesting solution in this post. He suggested to rewrite the canned 404 with an aspx page and then pull out the "offending URL". Based on this URL you can do a redirect. I tried it too and it worked. Setting up a wildcard is suggested very often, but I don't think it's a good idea. In 99% of those cases people needed this kind of extensionless redirect only. With a wildcard everything goes through the pipeline including images, stylesheets, media, you name it. I think the overhead doesn't justify it.
    Wednesday, April 28, 2004 12:15 PM
  • User-1645088262 posted
    If you want to imitate a virtual folder (where the folder doesn't really exist) then I think it's the better solution over using 404 pages. There is not much overhead at all with the static files as there is a handler specifically for them.
    Wednesday, April 28, 2004 2:25 PM
  • User-1391363652 posted
    Are wildcards supported in IIS 5?
    Wednesday, April 28, 2004 2:37 PM
  • User1025741586 posted
    If I map wildcards to ASP.NET, does IIS check to see whether an extensionless request (www.mysite.com/john) is a real directory before it passes the request to my handler? Or do I have to do that myself in the custom handler? E.g., if I have an actual file at /joe/default.aspx, but there is no directory called /john, how do I make sure www.mysite.com/john gets rewritten to www.mysite.com/users.aspx?userName=john but www.mysite.com/joe goes to www.mysite.com/joe/default.aspx
    Friday, July 30, 2004 10:57 AM
  • User1651711768 posted
    Try one of overloaded context.RewritePath. Get the details here.
    Sunday, August 1, 2004 4:32 AM
  • User1025741586 posted
    So it's up to me to check to see which paths correspond to actual directories, then try to rewrite the ones that don't. Thanks!
    Monday, August 2, 2004 10:03 AM