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

StackOverflow https://stackoverflow.com/questions/33089

  •  09-06-2019
  •  | 
  •  

我正在使用 ASP.NET 登录控件表单验证 用于 ASP.NET Web 应用程序的成员资格/凭据。它不断重定向到我的应用程序根目录下不存在的 Login.aspx 页面。我的登录页面位于一个文件夹内。

有帮助吗?

解决方案

使用表单项的 LoginUrl 属性?

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

其他提示

我在以下位置找到了答案 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>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top