Dealing with URLs containing reserved words (CON, PRN, LPT1, ...) ?

2 posts, 0 answers
  1. Greg Chung
    Greg Chung avatar
    48 posts
    Member since:
    Jul 2006

    Posted 17 Jun 2008 Link to this post

    I recently ran into a problem where IIS is refusing to handle a URL which contains one of the reserved words.  In my case, I accept URLs for company searches by their ticker symbol, in the form of http://<myhost>/search/ticker/<tickersymbol>

    At random, I tried searching for "CON" last night and found that http://<myhost>/search/ticker/con immediately generates an error in IIS.  aarghh!

    Is there a workaround for this?  Maybe an IIS config switch to allow these URLs through anyway?  googling for this problem turned up a couple other people describing this, but I found no solution, other than "don't do this!"  The only alternatives I see are to change the search URL to take the ticker symbol as a parameter instead (ugh), or to append a special character onto the ticker in the URL, like "/con_".  However, I'd much rather just have IIS not reject the URL in the first place, if that's possible.

    Any insight into dealing with this problem would be appreciated!

  2. Nicolaï
    Nicolaï avatar
    160 posts
    Member since:
    Apr 2008

    Posted 22 Dec 2009 Link to this post

    Is it an option to use: Server.HtmlEncode([string]) ?
    Not sure if that helps in this situation..
Back to Top