This is a migrated thread and some comments may be shown as answers.

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

1 Answer 35 Views
Miscellaneous
This is a migrated thread and some comments may be shown as answers.
Greg Chung
Top achievements
Rank 1
Greg Chung asked on 17 Jun 2008, 07:32 PM
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!

1 Answer, 1 is accepted

Sort by
0
Nicolaï
Top achievements
Rank 2
answered on 22 Dec 2009, 11:11 AM
Is it an option to use: Server.HtmlEncode([string]) ?
Not sure if that helps in this situation..
Tags
Miscellaneous
Asked by
Greg Chung
Top achievements
Rank 1
Answers by
Nicolaï
Top achievements
Rank 2
Share this question
or