0

我觉得我问这个问题是在打败一匹死马,但我只是不理解重定向......如果用户尝试在不登录的情况下访问仅限会员的网页,我如何将该用户重定向到日志在页面?在我的搜索中,我看到了一些关于修改我的 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>
4

1 回答 1

0

事实证明我是在正确的轨道上。我需要做的就是从以下位置修改身份验证模块:

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

至:

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

简单的错误每次都让我着迷。

于 2013-07-29T13:21:40.097 回答