How to use ASP.NET login controls when my Login.aspx is not at the root of my application?

I am using ASP.NET Login Controls and Form Authentication for Membership / Credentials for an ASP.NET Web Application. It is redirected to the Login.aspx page in the root of my application, which does not exist. My login page is in a folder.

+3
source share
2 answers

Use LoginUrl property for form element?

<authentication mode="Forms">
  <forms defaultUrl="~/Default.aspx" loginUrl="~/login.aspx" timeout="1440" ></forms>
</authentication>
+6
source

I found the answer on CoderSource.net . I had to put the correct path in 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>
+1
source

Source: https://habr.com/ru/post/1696574/


All Articles