How do I use ASP.NET Login Controls when my Login.aspx is not at the root of my application?
-
09-06-2019 - |
Question
I'm using the ASP.NET Login Controls and Forms Authentication for membership/credentials for an ASP.NET web application. It keeps redirecting to a Login.aspx page at the root of my application that does not exist. My login page is within a folder.
Solution
Use the LoginUrl property for the forms item?
<authentication mode="Forms">
<forms defaultUrl="~/Default.aspx" loginUrl="~/login.aspx" timeout="1440" ></forms>
</authentication>
OTHER TIPS
I found the answer at CoderSource.net. I had to put the correct path into my web.config file.
<?xml version="1.0"?>
<configuration>
<system.web>
...
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Forms">
<forms loginUrl="~/FolderName/Login.aspx" />
</authentication>
...
</system.web>
...
</configuration>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow