【问题标题】:Html landing page in asp.netasp.net 中的 Html 登陆页面
【发布时间】:2012-03-18 16:22:00
【问题描述】:

我的 asp.net 网站有一个 html 登录页面,但是我不能让它显示它总是进入登录页面。

我可以在 web.config 中设置什么来解决这个问题?

我试过了

 <authentication mode="Forms">
  <forms defaultUrl="index.html" loginUrl="~/Account/Login.aspx" timeout="2880" />
</authentication>

 <location path="index.html">
<system.web>
  <authorization>
    <allow users="?" />
  </authorization>
</system.web>

<defaultDocument>
  <files>
    <clear />
    <add value="index.html" />
  </files>
</defaultDocument>

一切都没有运气。请帮忙 提前致谢

这是我的完整 web.config

 <configuration>
  <connectionStrings>
    <!--<add name="ApplicationServices" connectionString="Data Source=.\sqlexpress;Initial Catalog=ArctixDb;Integrated Security=SSPI;"/>-->
    <add name="ApplicationServices" connectionString="" />
    <add name="ArctixDbEntities" connectionString="" />
  </connectionStrings>
  <system.web>
    <customErrors mode="Off" />
    <httpHandlers>
      <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
        validate="false" />    
    </httpHandlers>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="Microsoft.ReportViewer.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
      </assemblies>
      <buildProviders>
        <add extension=".rdlc" type="Microsoft.Reporting.RdlBuildProvider, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      </buildProviders>
    </compilation>
    <authentication mode="Forms">
      <forms defaultUrl="index.html" loginUrl="~/Account/Login.aspx" timeout="2880" />
    </authentication>
    <membership>
      <providers>
        <clear/>
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
      </providers>
    </membership>
    <profile>
      <providers>
        <clear/>
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
      </providers>
    </profile>
    <roleManager enabled="false">
      <providers>
        <clear/>
        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
        <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
      </providers>
    </roleManager>
    <authorization>
      <deny users="?" />
    </authorization>
  </system.web>
  <location allowOverride="true">
    <appSettings>
      <add key="SMTPServer" value="" />
      <add key="SMTPServerPort" value="25" />
      <add key="SMTPServerSSL" value="false" />
      <add key="SMTPUsername" value="" />
      <add key="SMTPPassword" value="" />
      <add key="SystemEmailAddress" value="" />
      <add key="SystemEmailAddressName" value="" />
    </appSettings>
  </location>
  <location path="Styles">
    <system.web>
      <authorization>
        <allow users="?" />
      </authorization>
    </system.web>
  </location>
  <location path="Account">
    <system.web>
      <authorization>
        <allow users="?" />
      </authorization>
    </system.web>
  </location>
  <location path="images">
    <system.web>
      <authorization>
        <allow users="?" />
      </authorization>
    </system.web>
  </location>
  <location path="index.html">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <defaultDocument>
      <files>
        <clear />
        <add value="index.html" />
      </files>
    </defaultDocument>
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>
      <add name="ReportViewerWebControlHandler" preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

    </handlers>
  </system.webServer>
</configuration>

【问题讨论】:

  • 我托管在一个提供商那里,该提供商已将那里的默认页面设置为 index.html。如果我删除 web.config 它可以工作
  • 你是否在授权下尝试过
  • web.config 中有一些东西强制它登录。
  • 允许用户="*"。尝试使用 * 而不是 ?
  • 看看这篇文章,stackoverflow.com/questions/1913058/set-default-page-in-asp-net。可能会有所帮助

标签: asp.net html forms authentication


【解决方案1】:

我最终只是将我的登录页面设置为登录页面

【讨论】:

    【解决方案2】:

    您可以按如下方式构建您的网站吗?

    • 允许根目录/styles/etc允许匿名访问
    • 使用自己的 web.config 添加一个“安全”目录,指定表单身份验证

    “安全”之外的任何内容都可以访问。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-06
      相关资源
      最近更新 更多