当我的Login.aspx不在我的应用程序的根目录时,如何使用ASP.NET登录控件?

时间:2008-08-28 18:55:33

标签: asp.net forms-authentication

我正在使用ASP.NET Login ControlsForms Authentication获取ASP.NET Web应用程序的成员资格/凭据。它会一直重定向到我的应用程序根目录下不存在的Login.aspx页面。我的登录页面位于文件夹中。

2 个答案:

答案 0 :(得分:6)

对表单项使用LoginUrl属性吗?

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

答案 1 :(得分:1)

我在CoderSource.net找到答案。我必须将正确的路径放入我的web.config文件中。

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