Dennis Vella
Dennis Vella

Reputation: 21

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 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

Upvotes: 0

Views: 4190

Answers (2)

BentOnCoding
BentOnCoding

Reputation: 28178

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

Upvotes: 0

Richard Adnams
Richard Adnams

Reputation: 3128

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.

Upvotes: 3

Related Questions