Asp.net Can';尝试访问仅限成员的页面时,请不要将用户重定向到登录页面

Asp.net Can';尝试访问仅限成员的页面时,请不要将用户重定向到登录页面,asp.net,redirect,Asp.net,Redirect,我觉得我问这个问题是在打一匹死马,但我只是不理解重定向。。。如果用户试图在不登录的情况下访问仅限成员的网页,如何将该用户重定向到登录页面?在我的搜索中,我看到了一些关于修改我的web.config文件的参考资料,但是,没有什么能让我觉得这是让它正常工作的关键。。。当我在未经身份验证的情况下尝试访问仅限成员的页面时,会出现404错误。当我通过身份验证时,页面加载正常。。。我错过了什么 <?xml version="1.0"?> <!-- For more information

我觉得我问这个问题是在打一匹死马,但我只是不理解重定向。。。如果用户试图在不登录的情况下访问仅限成员的网页,如何将该用户重定向到登录页面?在我的搜索中,我看到了一些关于修改我的web.config文件的参考资料,但是,没有什么能让我觉得这是让它正常工作的关键。。。当我在未经身份验证的情况下尝试访问仅限成员的页面时,会出现404错误。当我通过身份验证时,页面加载正常。。。我错过了什么

<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
  <appSettings>
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
  </appSettings>
  <connectionStrings>
    <add name="LOTOConnectionString" connectionString="Data Source=WIWRMS-SQLD2\SQLD2;Initial Catalog=LOTO;User ID=LOTO_ADMIN;Password=lotoadmin"
      providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
    <authentication mode="Forms">
      <forms name=".ASPXFORMSAUTH" loginUrl="~/Account/Login" defaultUrl="~/" />
    </authentication>
    <membership defaultProvider="SqlProvider" >
      <providers>
        <clear />
        <add
          name="SqlProvider"
          type="System.Web.Security.SqlMembershipProvider"
          connectionStringName="LOTOConnectionString"
          applicationName="/"
          enablePasswordRetrieval="false"
          enablePasswordReset="true"
          requiresQuestionAndAnswer="true"
          requiresUniqueEmail="true"
          passwordFormat="Hashed"/>
      </providers>
    </membership>
    <pages enableEventValidation="false" />
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.5">
      <assemblies>
        <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
        <add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
      </assemblies>
    </compilation>
    <httpRuntime targetFramework="4.5"/>
  </system.web>
</configuration>

结果证明我的思路是正确的。我需要做的只是从以下位置修改身份验证模块:

<authentication mode="Forms">
  <forms name=".ASPXFORMSAUTH" loginUrl="~/Account/Login" defaultUrl="~/" />
</authentication>

致:


这些简单的错误每次都让我难受

<authentication mode="Forms">
  <forms name=".ASPXFORMSAUTH" loginUrl="~/Account/Login.aspx" defaultUrl="~/" />
</authentication>