How do I use ASP.NET Login Controls when my Login.

2019-05-11 08:30发布

问题:

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.

回答1:

Use the LoginUrl property for the forms item?

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


回答2:

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>