We are using forms authentication with roles to restrict access to certain pages and areas of a website. When a user is not authorised, either because they are not logged in or do not have the required role, they are redirected to the login page with a returnto url.
We define what access is required in the web.config using the authorization tags like:
<authorization>
<deny users="?"/>
</authorization>
The web application we are working on uses HttpContext.Current.RewritePath for friendlier URLs and dynamic pages. So that a request for "/MyPages/MyDocuments.aspx! gets re-written to "/PageTypes/Library.aspx" or something along those lines.
However when the application redirects because a user does not have permission the ReWritePath is used instead of the Raw URL.
What do I need to override so that the returnto URL is the requested URL instead of the actual psychical path?