I typically use URL rewriting to pass content IDs to my website, so this
Foo.1.aspx
rewrites to
Foo.aspx?id=1
For a specific application I need to pass in multiple IDs to a single page, so I've rewritten things to accept this:
Foo.1,2,3,4,5.aspx
This works fine in Cassini (the built-in ad hoc web server for Visual Studio) but gives me "Internet Explorer cannot display the webpage" when I try it on a live server running IIS. Is this an IIS limitation? Should I just use dashes or underscores instead of commas?
The right way to accept multiple ids is like this:
Note that's just what the target is. When re-writing urls, you can set your own rules to a certain extent for what you want the source to look like.
I had to learn this on StackOverflow, too. See this question:
Split out ints from string
In addition to the answer by ConroyP, below is another citation to the RFC. It notes a number of unsafe characters, but does not mention the comma (suggesting that the comma is safe):
Try using
%2c
in the URL to replace the commas.If you'd put in place a front controller then you could do something like;
The Front Controller would pick up the method name and the parameters to pass to it. This is a pretty common technique nowadays.
The comma is allowed in the path, query string and fragment according to spec. It wouldn't surprise me if IE doesn't conform to the spec though. Try the entity as Claudiu suggests, but I don't know why that would be necessary.
Commas are allowed in the filename part of a URL, but are reserved characters in the domain*, as far as I know.
What version of IE are you using? I've come across the odd report of IE5.5 truncating URLs on a comma (link here, but have tested URLs with commas in IE7 and it seems to be OK, so if there was an IE bug, it doesn't seem to be there any more - could it be an IIS issue?
I'm wondering if the page error is due to a rule failure with the
mod_rewrite
- can you post the rule which is matching multiple ids and passing them off to yourFoo.aspx
? Is there any chance that it's only matchingFoo.N,N
, and failing on more commas?* From the URI RFC: