How to transfer execution to ASPX page from custom handler

  • Thread starter Stanislav Ostachevski
  • 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.
 
J

John Saunders

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top