Reputation: 12560
I have an authentication script (CheckLogin.aspx
), and if any of the credentials do not match my application will redirect (via Server.Transfer
) to the access denied page (forbidden.aspx
). Each time my script runs,it gets an InvalidOperationException: Failed to map the path '/forbidden.aspx'
. Here is a mockup of my applications file structure:
<root>
..default.aspx
..forbidden.aspx
..<inc>
....scripts.js
..<auth>
....CheckLogin.aspx
As you can see, the CheckLogin.aspx
page is in a folder inside the root, and the forbidden.aspx
page is inside the root itself. The path I am telling my application to redirect to is /forbidden.aspx
.
Upvotes: 1
Views: 2983
Reputation: 27441
Are you using "~/..." to make sure all your paths are relative?
By the way, you should just set up page access via Web.config, by using the <location>
tags. That way you can have some sort of role-based access, without much custom code.
Upvotes: 0
Reputation: 32841
Sometimes you have to precede the page path with a tilde to indicate the root directory:
'~/forbidden.aspx'
Upvotes: 4