M
MWells
I've encountered an interesting issue regarding Url encoding that I'm
hopeful someone can shed some light on.
I have some vanity Url's that have to contain filename content, using the
file naming rules of the Windows file system. Because spaces are plus (+)
signs are permitted in Windows filenames, I might have a file called;
"test+test test.txt"
And the vanity Url that references it might be something like;
http://yadda/getfile/test+test test.txt
To avoid Url problems, I encode the filename portion of the vanity Url using
Server.UrlEncode () and I get...
http://yadda/getfile/test+test+test.txt
Looking good so far, but in my HttpModule I run into a serious issue; the
Url value that I get through Request.RawUrl appears with the %2B translated,
as follows...
http://yadda/getfile/test+test+test.txt
This means that I can't distinguish between plus signs and spaces. When I
decode, I get;
http://yadda/getfile/test test test.txt
Which makes it impossible for me to locate the file the user has requested.
I've tested this many times, refreshing, viewing the results in trace.axd,
and the problem is very consistent. I can see the %2B in the Url bar, but
it's being decoded before the value is stored in Request.RawUrl. None of
the other header variables (as perused in trace.axd) show the %2B either.
I haven't isolated the location of the problem yet; it's somewhere between
the Internet Explorer Url bar and the start of execution of my HttpModule.
The problem might be IE6, or IIS, or .NET; I'm hopeful that someone already
knows the answer before I have to put on the hardhat and go spelunking.
Also while I'd like to understand it, I'm more immediately concerned about a
solution, so ideas are welcome. Clearly, I'd like to avoid my own
additional encoding scheme if I can avoid it...
Many thanks.
/// M
hopeful someone can shed some light on.
I have some vanity Url's that have to contain filename content, using the
file naming rules of the Windows file system. Because spaces are plus (+)
signs are permitted in Windows filenames, I might have a file called;
"test+test test.txt"
And the vanity Url that references it might be something like;
http://yadda/getfile/test+test test.txt
To avoid Url problems, I encode the filename portion of the vanity Url using
Server.UrlEncode () and I get...
http://yadda/getfile/test+test+test.txt
Looking good so far, but in my HttpModule I run into a serious issue; the
Url value that I get through Request.RawUrl appears with the %2B translated,
as follows...
http://yadda/getfile/test+test+test.txt
This means that I can't distinguish between plus signs and spaces. When I
decode, I get;
http://yadda/getfile/test test test.txt
Which makes it impossible for me to locate the file the user has requested.
I've tested this many times, refreshing, viewing the results in trace.axd,
and the problem is very consistent. I can see the %2B in the Url bar, but
it's being decoded before the value is stored in Request.RawUrl. None of
the other header variables (as perused in trace.axd) show the %2B either.
I haven't isolated the location of the problem yet; it's somewhere between
the Internet Explorer Url bar and the start of execution of my HttpModule.
The problem might be IE6, or IIS, or .NET; I'm hopeful that someone already
knows the answer before I have to put on the hardhat and go spelunking.
Also while I'd like to understand it, I'm more immediately concerned about a
solution, so ideas are welcome. Clearly, I'd like to avoid my own
additional encoding scheme if I can avoid it...
Many thanks.
/// M