本文介绍了提高asp.net的时间Forms身份验证甚至更改时间web.config文件它不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的web.config文件code,我使用窗体身份验证。我增加了超时时间,但其仍无法与在2分钟内我的应用程序获取注销工作再次自动用户不得不再次登录。

 <?XML版本=1.0编码=UTF-8&GT?;
    <结构>
      < configSections>
        <! - 有关Entity Framework的配置的详细信息,请访问http://go.microsoft.com/fwlink/?LinkID=237468 - >
        <节名称=的EntityFrameworkTYPE =System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection,的EntityFramework,版本6.0.0.0 =文化=中性公钥= b77a5c561934e089requirePermission =FALSE/>
      < / configSections>
      <&是connectionStrings GT;        <添加名称=DBCS的connectionString =数据源= 105.55.191.106;初始目录=卡车;用户ID =吉里什;密码= Girish123 @#/>
        <添加名称=Truck_ManagementConnectionString的connectionString =数据源= 105.55.191.106;初始目录=卡车;用户ID =吉里什;密码= Girish123 @#;!的providerName =System.Data.SqlClient的/>
      < /&是connectionStrings GT;
      < system.webServer>        < defaultDocument>
          <&文件GT;
            <清/>
            <增加价值=HomeMain.aspx/>
          < /文件>
        < / defaultDocument>
        < httpErrors errorMode =详细/>
        < ASP scriptErrorSentToBrowser =真/>
        <验证validateIntegratedModeConfiguration =FALSE/>
        <模块runAllManagedModulesForAllRequests =真正的>
          <清除NAME =UrlRoutingModule/>
          <添加名称=UrlRoutingModuleTYPE =System.Web.Routing.UrlRoutingModule,System.Web程序,版本= 4.0.0.0,文化=中性公钥= b03f5f7f11d50a3a/>
        < /模块>
        <&处理GT;
          <添加名称=UrlRoutingHandlerpreCondition =integratedMode动词=*路径=UrlRouting.axdTYPE =System.Web.HttpForbiddenHandler,System.Web程序,版本= 2.0.0.0,文化=中性公钥= b03f5f7f11d50a3a/>
        < /处理器>
      < /system.webServer>
      <&的System.Web GT;
        <的sessionState超时=60/>
        <跟踪启用=真pageOutput =假requestLimit =40设置LocalOnly =FALSE/>
        <的customErrors模式=关/>
        <身份验证模式=表格>
          <形式loginUrl =HomeMain.aspx超时=2880defaultUrl =NewtrucksValidations.aspx>
            <凭证了passwordFormat =清除>
              <使用者名称=拉杰什密码=拉杰什/>
              <使用者名称=Rajesh1密码=Rajesh1/>
            < /凭证>
          < /形式GT;
        < /认证>
        <授权>
          <拒绝用户=? />
        < /授权>
        <编译调试=真targetFramework =4.0/>
        <页面缓冲=真enableEventValidation =假>< /页>
      < /system.web>
      < system.net>      < /system.net>
      <&的appSettings GT;        <添加键=microsoft.visualstudio.teamsystems.aspnetdevserver:/ dxfsdVALUE =2772;真; 4952; 1; -8587766731921818473/>
        <添加键=microsoft.visualstudio.teamsystems.backupinfoVALUE =1; web.config.backup/>
        <添加键=令牌值=AFcWxV21C7fd0v3bYYYRCpSSRl31AZ8FkzH5YTJtR8RVkxY6oiRdbOtN/>
        <添加键=paypalemailVALUE =akshithrajesh290-facilitator_api1.gmail.com/>
        <! - 在这里,我使用沙箱网站的网址只有当你住在沙箱的变化主办活贝宝URL - >
        <添加键=PayPalSubmitUrlVALUE =htt​​ps://www.sandbox.paypal.com/cgi-bin/webscr/>
        <添加键=FailedURLVALUE =HTTP://本地主机:49666 / PayPalIntegration / Failed.aspx/>
        <! - 失败页面URL - >
        <添加键=SuccessURLVALUE =HTTP://本地主机:49666 / Default.aspx的/>
        <! - 成功页URL - >
      < /的appSettings>
      <&运行GT;
        < assemblyBinding的xmlns =瓮:架构 - 微软COM:asm.v1>< / assemblyBinding>
      < /运行>
      <&的EntityFramework GT;
        < defaultConnectionFactory TYPE =System.Data.Entity.Infrastructure.LocalDbConnectionFactory,的EntityFramework>
          <&参数GT;
            <参数值=11.0/>
          < /参数>
        < / defaultConnectionFactory>
        <供应商>
          <供应商invariantName =System.Data.SqlClient的TYPE =System.Data.Entity.SqlServer.SqlProviderServices,EntityFramework.SqlServer/>
        < /供应商>
      < /&的EntityFramework GT;
    < /结构>


解决方案

可能这是因为没有指定的machineKey 。你可以给它一个尝试 -

应用程序池可以定期回收。当回收时,ASP.NET将重新创建一个的machineKey ,如果没有一个在指定的web.config 。机密钥用于生成验证票,所以在新重建的machineKey使得这会导致用户注销当前验证票无效。该解决方案是增加一个<的machineKey方式> 的web.config 文件栏目

 <&的System.Web GT;<的machineKey的validationKey =19127329C4588866D1120D7146F4C6A7B53F29DBEF58F890decryptionKey =789AA0B220798EF1780914BBE9CCB681C285F31680014162验证=SHA1/>< /system.web>

有产生的machineKey的工具。你可以尝试 -

Below is My Web.config File Code I am using forms Authentication. I increased the Time out Time but still its not working with in 2 minutes My Application is Getting log out Automatically Again User had to sign in Again .

<?xml version="1.0" encoding="utf-8"?>
    <configuration>
      <configSections>
        <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
        <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
      </configSections>
      <connectionStrings>

        <add name="DBCS" connectionString="Data Source=105.55.191.106;Initial Catalog=Trucks;User ID=Girish;Password=Girish123!@#" />
        <add name="Truck_ManagementConnectionString" connectionString="Data Source=105.55.191.106;Initial Catalog=Trucks;User ID=Girish;Password=Girish123!@#;" providerName="System.Data.SqlClient" />
      </connectionStrings>
      <system.webServer>

        <defaultDocument>
          <files>
            <clear />
            <add value="HomeMain.aspx" />
          </files>
        </defaultDocument>
        <httpErrors errorMode="Detailed" />
        <asp scriptErrorSentToBrowser="true" />
        <validation validateIntegratedModeConfiguration="false" />
        <modules runAllManagedModulesForAllRequests="true">
          <remove name="UrlRoutingModule" />
          <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        </modules>
        <handlers>
          <add name="UrlRoutingHandler" preCondition="integratedMode" verb="*" path="UrlRouting.axd" type="System.Web.HttpForbiddenHandler, System.Web,   Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        </handlers>
      </system.webServer>
      <system.web>
        <sessionState timeout="60" />
        <trace enabled="true" pageOutput="false" requestLimit="40" localOnly="false" />
        <customErrors mode="Off" />
        <authentication mode="Forms">
          <forms loginUrl="HomeMain.aspx"  timeout="2880" defaultUrl="NewtrucksValidations.aspx">
            <credentials passwordFormat="Clear">
              <user name="Rajesh" password="Rajesh" />
              <user name="Rajesh1" password="Rajesh1" />
            </credentials>
          </forms>
        </authentication>
        <authorization>
          <deny users="?" />
        </authorization>
        <compilation debug="true" targetFramework="4.0" />
        <pages buffer="true" enableEventValidation="false"></pages>
      </system.web>
      <system.net>

      </system.net>
      <appSettings>

        <add key="microsoft.visualstudio.teamsystems.aspnetdevserver:/dxfsd" value="2772;True;4952;1;-8587766731921818473" />
        <add key="microsoft.visualstudio.teamsystems.backupinfo" value="1;web.config.backup" />
        <add key="token" value="AFcWxV21C7fd0v3bYYYRCpSSRl31AZ8FkzH5YTJtR8RVkxY6oiRdbOtN" />
        <add key="paypalemail" value="akshithrajesh290-facilitator_api1.gmail.com" />
        <!--Here i used sandbox site url only if you hosted in live change sandbox to live paypal URL-->
        <add key="PayPalSubmitUrl" value="https://www.sandbox.paypal.com/cgi-bin/webscr" />
        <add key="FailedURL" value="http://localhost:49666/PayPalIntegration/Failed.aspx" />
        <!--Failed Page URL-->
        <add key="SuccessURL" value="http://localhost:49666/Default.aspx" />
        <!--Success Page URL-->
      </appSettings>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"></assemblyBinding>
      </runtime>
      <entityFramework>
        <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
          <parameters>
            <parameter value="v11.0" />
          </parameters>
        </defaultConnectionFactory>
        <providers>
          <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        </providers>
      </entityFramework>
    </configuration>
解决方案

May be this is because of there is no machinekey specified. You can give it a try -

Application pools can regularly be recycled. When recycling occurs, the ASP.NET will recreate a MachineKey, if there isn’t one specified in web.config. Machine key is used to generate Authentication ticket, so the newly recreated machinekey makes the current Authentication ticket invalid which causes users to logout. The solution to that is to add a <machinekey> section in the web.config file.

<system.web>

<machineKey validationKey="19127329C4588866D1120D7146F4C6A7B53F29DBEF58F890" decryptionKey="789AA0B220798EF1780914BBE9CCB681C285F31680014162" validation="SHA1" />

</system.web>

There are many tools for generating machinekey. you may try - http://www.developerfusion.com/tools/generatemachinekey/

这篇关于提高asp.net的时间Forms身份验证甚至更改时间web.config文件它不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 09:00