Dynamically setting default url in asp.net forms authentication
I have been trying to set the default url but it is not redirecting to the page that I want. The defaultUrl="admin/Home.aspx"
is keeping redirecting back开发者_如何学Go to the login.aspx
can someone please help?
Below is the code i am doing in the web.config
<authentication mode="Forms">
<forms loginUrl="~/Login.aspx" timeout="20" defaultUrl="admin/Home.aspx" />
</authentication>
the url after being redirected is as follows
/Login.aspx?ReturnUrl=%2fadmin%2fHome.aspx
what do the %2f
mean?
Thanks
From what I can see it's redirecting you back to the login page because your not authenticated? I maybe wrong on that though.
The %2f is an url encoded forward slash.
The WebConfigurationManager is the class you want to look at.
It doesn't specifically address the web.config tag you are trying to edit which is:
<forms loginUri="http://website.com/login.aspx" />
But as long as there are no restrictions on that tag this should solve your problems.
Here is the docs.
http://msdn.microsoft.com/en-us/library/system.web.configuration.webconfigurationmanager.aspx
精彩评论