为什么在asp.net(C#)中服务器上的会话丢失 [英] why session loss on server in asp.net(C#)

查看:83
本文介绍了为什么在asp.net(C#)中服务器上的会话丢失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尊敬的先生/女士


我是Shailendra Singh,是.Net的新手.我在Project中遇到错误.错误是asp.net(C#)中服务器上的会话丢失.请为特定问题提供任何帮助.

在此先感谢
我的web.config文件.

 <?  xml    版本  ="  ? > 
<!-  
  有关如何配置ASP.NET应用程序的更多信息,请访问
  http://go.microsoft.com/fwlink/?LinkId=152368
   ->  
<  配置 > 
    <   connectionStrings  > 
        <!-  < add name ="ConnStr" connectionString ="Server = indoreserver.com;数据库= parthagarai_GPS; UID = parthagarai_GPS;密码= jeet1244; MultipleActiveResultSets = True"/>  <!-  < add name ="ConnStr" connectionString =数据源= PC-1 \ SQLEXPRESS;数据库= GPS;集成安全性= True; MultipleActiveResultSets = True"/>  <  添加    ="   con"  connectionString   数据源= 111.222.333.444;数据库= aaryamans_Teleshop_data; UID = shailendra;密码= XXXXXX; MultipleActiveResultSets =真" > ; 
    <  /connectionStrings  > 
    <   system.web  > 
    <  页面    ="   false" / <   httpRuntime     ="   90"  maxRequestLength   > 4096"     useFullyQualifiedRedirectUrl   ="  false"  minFreeThreads    8"  minLocalRequestFreeThreads   ="     appRequestQu eueLimit   ="     enableVersionHeader   ="  / > 
        <!-  动态调试编译
          将编译设置为debug ="true"以启用ASPX调试.否则,将此值设置为
          false将提高此应用程序的运行时性能.
          设置编译debug ="true"以插入调试符号(.pdb信息)
          进入已编译的页面.因为这会创建一个较大的文件,该文件将执行
          更慢的是,只有在调试时才应将此值设置为true,
          在其他所有时间均为假.有关更多信息,请参阅有关以下内容的文档:
          调试ASP.NET文件.
     ->  
        <  编译    ="   c#" 调试   true" > 
            <  装配体 > 
                <  添加    ="   System.Windows.Forms,Version = 2.0.0.0,Culture =中性,PublicKeyToken = B77A5C561934E089"  / > 
            <  /assembly  >  <  /compilation  > 
        <!-  自定义错误消息
          设置customErrors mode ="On"或"RemoteOnly"以启用自定义错误消息,将"Off"禁用.
          添加< error>您要处理的每个错误的标签.
          开"始终显示自定义(友好)消息.
          关"始终显示详细的ASP.NET错误信息.
          仅远程"仅向未运行的用户显示自定义(友好)消息
           在本地Web服务器上.为了安全起见,建议使用此设置,因此
           您不向远程客户端显示应用程序详细信息.
     ->  
        <   customErrors     ="  关闭" > 
        <!-  认证
          本部分设置应用程序的身份验证策略.可能的模式是"Windows",
          表格",护照"和无"
          无"不执行身份验证.
          IIS根据以下条件执行"Windows" IIS身份验证(基本Windows,摘要Windows或集成Windows):
           应用程序的设置.必须在IIS中禁用匿名访问.
          表单"您提供了一个自定义表单(网页),供用户输入其凭据,然后
           您可以在应用程序中对它们进行身份验证.用户凭证令牌存储在cookie中.
          通过提供的集中式身份验证服务执行护照"身份验证
           由Microsoft提供,用于成员网站的单一登录和核心配置文件服务.
     ->  
        <!-  <身份验证模式="Windows"/>  ->  
        <!-  授权
          本部分设置应用程序的授权策略.您可以允许或拒绝访问
          按用户或角色访问应用程序资源.通配符:"*"表示所有人,?"表示匿名
          (未经身份验证的)用户.
     ->  
        <  授权 > 
            <  允许    ="   *" > 
            <!-  允许所有用户 ->  
            <!-  < allow users ="[逗号分隔的列表用户]
                             role ="[角色的逗号分隔列表]"/>
                  < deny users ="[用逗号分隔的用户列表]"
                             role ="[角色的逗号分隔列表]"/>
             ->  
        <  /authorization  > 
        <!-  应用级跟踪日志记录
          应用程序级跟踪可为应用程序中的每个页面启用跟踪日志输出.
          设置trace enabled ="true"以启用应用程序跟踪日志记录.如果pageOutput ="true",则
          跟踪信息将显示在每页底部.否则,您可以查看
          通过从Web应用程序浏览"trace.axd"页面来获取应用程序跟踪日志
          根.
     ->  
        <  跟踪     ="   requestLimit   > 10"     pageOutput   ="  false"  traceMode    SortByTime"  localOnly   ="  / > 
        <!-  会话状态设置
          默认情况下,ASP.NET使用cookie来识别哪些请求属于特定会话.
          如果cookie不可用,可以通过将会话标识符添加到URL来跟踪会话.
          要禁用cookie,请设置sessionState cookieless ="true".
     ->  
    <   sessionState     ="   InProc"  stateConnectionString    tcpip = 127.0 .0.1:42424"  sqlConnectionString   数据源= 127.0.0.1; Trusted_Connection =是" 无cookie    false" 超时  ="  / <!-  全球化
          本部分设置应用程序的全球化设置.
     ->  
        <  全球化    ="   utf-8"  responseEncoding    utf -8" > 
    <  /system.web  > 
    <   system.codedom  > 
    <  /system.codedom  > 
    <   system.webServer  > 
    <  /system.webServer  > 
<  /configuration  >  

解决方案

由于超时导致服务器会话丢失.您可以使用web.config中的以下语句来增加时间,-
< pre lang ="xml">& lt; system.web& gt;
& lt; sessionState timeout =& 540& quot;/& gt;</pre>


您需要在WEB.Config中增加Session timout

Dear sir/Mam


I am Shailendra Singh and I am new to .Net . I am getting an error in Project. The error is session loss on server in asp.net(C#) .Please Any help for particular problem .

Thanks In Advance
MY web.config file .

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=152368
  -->
<configuration>
    <connectionStrings>
        <!--<add name="ConnStr" connectionString="Server=indoreserver.com;Database=parthagarai_GPS;UID=parthagarai_GPS;Password=jeet1244;MultipleActiveResultSets=True"/>-->
        <!--<add name="ConnStr" connectionString="Data Source=PC-1\SQLEXPRESS;Database=GPS;Integrated Security=True;MultipleActiveResultSets=True "/>-->
        <add name="con" connectionString="Data Source=111.222.333.444;Database=aaryamans_Teleshop_data;UID=shailendra;Password=XXXXXX;MultipleActiveResultSets=True "/>
    </connectionStrings>
    <system.web>
    <pages enableViewStateMac="false" />
        <httpRuntime executionTimeout="90" maxRequestLength="4096" useFullyQualifiedRedirectUrl="false" minFreeThreads="8" minLocalRequestFreeThreads="4" appRequestQueueLimit="100" enableVersionHeader="true"/>
        <!--  DYNAMIC DEBUG COMPILATION
          Set compilation debug="true" to enable ASPX debugging.  Otherwise, setting this value to
          false will improve runtime performance of this application.
          Set compilation debug="true" to insert debugging symbols (.pdb information)
          into the compiled page. Because this creates a larger file that executes
          more slowly, you should set this value to true only when debugging and to
          false at all other times. For more information, refer to the documentation about
          debugging ASP.NET files.
    -->
        <compilation defaultLanguage="c#" debug="true">
            <assemblies>
                <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
            </assemblies></compilation>
        <!--  CUSTOM ERROR MESSAGES
          Set customErrors mode="On" or "RemoteOnly" to enable custom error messages, "Off" to disable.
          Add <error> tags for each of the errors you want to handle.
          "On" Always display custom (friendly) messages.
          "Off" Always display detailed ASP.NET error information.
          "RemoteOnly" Display custom (friendly) messages only to users not running
           on the local Web server. This setting is recommended for security purposes, so
           that you do not display application detail information to remote clients.
    -->
        <customErrors mode="Off"/>
        <!--  AUTHENTICATION
          This section sets the authentication policies of the application. Possible modes are "Windows",
          "Forms", "Passport" and "None"
          "None" No authentication is performed.
          "Windows" IIS performs authentication (Basic, Digest, or Integrated Windows) according to
           its settings for the application. Anonymous access must be disabled in IIS.
          "Forms" You provide a custom form (Web page) for users to enter their credentials, and then
           you authenticate them in your application. A user credential token is stored in a cookie.
          "Passport" Authentication is performed via a centralized authentication service provided
           by Microsoft that offers a single logon and core profile services for member sites.
    -->
        <!--<authentication mode="Windows"/>-->
        <!--  AUTHORIZATION
          This section sets the authorization policies of the application. You can allow or deny access
          to application resources by user or role. Wildcards: "*" mean everyone, "?" means anonymous
          (unauthenticated) users.
    -->
        <authorization>
            <allow users="*"/>
            <!-- Allow all users -->
            <!--  <allow     users="[comma separated list of users]"
                             roles="[comma separated list of roles]"/>
                  <deny      users="[comma separated list of users]"
                             roles="[comma separated list of roles]"/>
            -->
        </authorization>
        <!--  APPLICATION-LEVEL TRACE LOGGING
          Application-level tracing enables trace log output for every page within an application.
          Set trace enabled="true" to enable application trace logging.  If pageOutput="true", the
          trace information will be displayed at the bottom of each page.  Otherwise, you can view the
          application trace log by browsing the "trace.axd" page from your web application
          root.
    -->
        <trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true"/>
        <!--  SESSION STATE SETTINGS
          By default ASP.NET uses cookies to identify which requests belong to a particular session.
          If cookies are not available, a session can be tracked by adding a session identifier to the URL.
          To disable cookies, set sessionState cookieless="true".
    -->
    <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="60"/>
        <!--  GLOBALIZATION
          This section sets the globalization settings of the application.
    -->
        <globalization requestEncoding="utf-8" responseEncoding="utf-8"/>
    </system.web>
    <system.codedom>
    </system.codedom>
    <system.webServer>
    </system.webServer>
</configuration>

解决方案

Session loss in server because of time out. You can increase time with the following statement in web.config,-
<pre lang="xml">&lt;system.web&gt;
&lt;sessionState timeout=&quot;540&quot;/&gt;</pre>


You need to increase the Session timout in WEB.Config


这篇关于为什么在asp.net(C#)中服务器上的会话丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆