How to transfer execution to ASPX page from custom handler

  • Thread starter Thread starter Stanislav Ostachevski
  • Start date Start date
S

Stanislav Ostachevski

Hello,

My app needs to map calls to "virtual files" to ASPX parametrized pages,
without showing user actual page address.
I.e, I want to catch calls to
http://myserver.com/products/id_product/somefeature.ashx
and redirect them to
http://products.myserver.com/product.aspx?id=id_product&features=....
but I don't want to reveal the actual URL of product.aspx
I catch all calls to ashx files by custom HTTP handler.
There's a problem: I can't use Server.Transfer call due to IIS redirection
issue (IIS can't redirect call to another DLL)
Microsoft suggests using Page.Redirect, but in this case new address will be
revealed, so I can't do so.

And I can't get reference to private PageHTTPHandler class.
Any advise would be greatly appreciated.
 
Stanislav Ostachevski said:
Hello,

My app needs to map calls to "virtual files" to ASPX parametrized pages,
without showing user actual page address.
I.e, I want to catch calls to
http://myserver.com/products/id_product/somefeature.ashx
and redirect them to
http://products.myserver.com/product.aspx?id=id_product&features=....
but I don't want to reveal the actual URL of product.aspx
I catch all calls to ashx files by custom HTTP handler.
There's a problem: I can't use Server.Transfer call due to IIS redirection
issue (IIS can't redirect call to another DLL)
Microsoft suggests using Page.Redirect, but in this case new address will be
revealed, so I can't do so.

And I can't get reference to private PageHTTPHandler class.
Any advise would be greatly appreciated.

This sort of thing should be done in an HttpModule, not an HttpHandler.
You're not actually "handling" the request. Instead you're modifying it and
then allowing the request to pass to the handler.

Your handler could check the request and do nothing if it's not a request
for a .ashx page. Otherwise, it could modify the URL with
HttpContext.RewritePath. The actual handler for .ashx pages should be the
same one that handles .aspx pages.

John
 
Back
Top