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

时间:2020-03-05 18:44:36  来源:igfitidea点击:

我正在使用ASP.NET登录控件和表单身份验证作为ASP.NET Web应用程序的成员身份/凭证。它一直重定向到我的应用程序根目录中不存在的Login.aspx页面。我的登录页面在一个文件夹中。

解决方案

回答

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

回答

对表单项使用LoginUrl属性吗?

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