I use HttpContext.RewritePath to do the URL rewrite, most pages in the site will be rewrriten to the same aspx page(handler.aspx).
Exampe: "[domain]/pc-test/" will be written to handler.aspx. [Page output: This is pc-test]
"[domain]/pc-test/a.html" will be wriiten to handler.aspx as well.(This is a bad case for testing)[Page output: This is pc-test]
Note: In handler.aspx will do different thing based on different URL.But I didn't just check the "pc-test" and ignore the string after that, so the output of these two requests are same.
I got a issue, if following two requests are visited in a very short duration
"[domain]/pc-test/a.html?p=2"[Page output: This is pc-test page 2]
"[domain]/pc-test/a.html?p=3"[Page output: This is pc-test page 3]
HttpContext.RewritePath will not work for any request after that. handler.aspx won't be called, and the page output will always be 'This is pc-test page 3' no matter what URL entered. Http status code is 200 when the issue occurs. Also if visit the real
aspx page(handler.aspx), it will display the same content 'This is pc-test page 3' as well. And this issue can be resolved by recycleing app pool in IIS.
But if visit these two request with a delay, for example visit "[domain]/pc-test/a.html?p=2" first and wait 3-5 secondes, then visit "[domain]/pc-test/a.html?p=3". Everything works fine in this case.
Any potential reason may cause this issue?
Note: a.html doesn't exist, the URL is typed maually for testing.
EricLiu0614
0 Points
3 Posts
RewritePath not working
Dec 07, 2012 02:33 PM|LINK
Hi Guys,
I got a issue about HttpContext.RewritePath
Enviroment: Windows 2008 r2, IIS 7.0
I use HttpContext.RewritePath to do the URL rewrite, most pages in the site will be rewrriten to the same aspx page(handler.aspx).
Exampe: "[domain]/pc-test/" will be written to handler.aspx. [Page output: This is pc-test]
"[domain]/pc-test/a.html" will be wriiten to handler.aspx as well.(This is a bad case for testing)[Page output: This is pc-test]
Note: In handler.aspx will do different thing based on different URL.But I didn't just check the "pc-test" and ignore the string after that, so the output of these two requests are same.
I got a issue, if following two requests are visited in a very short duration
"[domain]/pc-test/a.html?p=2"[Page output: This is pc-test page 2]
"[domain]/pc-test/a.html?p=3"[Page output: This is pc-test page 3]
HttpContext.RewritePath will not work for any request after that. handler.aspx won't be called, and the page output will always be 'This is pc-test page 3' no matter what URL entered. Http status code is 200 when the issue occurs. Also if visit the real aspx page(handler.aspx), it will display the same content 'This is pc-test page 3' as well. And this issue can be resolved by recycleing app pool in IIS.
But if visit these two request with a delay, for example visit "[domain]/pc-test/a.html?p=2" first and wait 3-5 secondes, then visit "[domain]/pc-test/a.html?p=3". Everything works fine in this case.
Any potential reason may cause this issue?
Note: a.html doesn't exist, the URL is typed maually for testing.
Kelmen
Member
180 Points
78 Posts
Re: RewritePath not working
Dec 26, 2012 03:37 AM|LINK
just idea:
1) if you using HttpHandler, may need to look into the Reusable property
2) I suggest use a routing debugger, maybe it's due to the routing selection
http://haacked.com/archive/2011/04/12/routedebugger-2.aspx
the site in not updated with latest details, once put the dll in your bin, set this below in web.config appsettings
<add key="RouteDebugger:Enabled" value="true" />
You should able to see which route been selected.