zoukankan      html  css  js  c++  java
  • IS6.0 应用程序池Web园导致Session丢失

    If you are running in IIS6 mode, your web sites will be using Application
    Pools. If your app pools are set to run using multiple processes, then cache
    & session information will be inconsistently accessible to aspx pages. Check
    the # of processes for your IIS 6 app pool. If it's >1, then that's the
    cause. Or if different vdirs on your site have different pools, that's would
    also cause the results you're seeing.

    Why? Imagine your app pool has two processes, A & B. An ASPX page stores an
    item in the cache or session. Through random luck, it gets stored in process
    A. Now the user requests another page & asks for that item from cache or
    session. But this time, the ASPX page might look in process B. Since the
    item is stored in process A, not process B, it will come up emptyhanded. If
    your ASPX page then re-stores the item during this call, it'll store it in
    process B. And now you have two (possibly different) versions of the item,
    one in process A, one in process B. And who knows which one will get pulled
    up on the next ASPX request.

    Also, be cautious if you assume the cache will stay "in sync" with a
    database. Memory conditions, app restarts, etc. can expire items in the
    cache.
     
     
    问: IIS 6.0 具有一个名为 Web 园的新功能,有了它,可以将应用程序池配置为使用多个工作进程。IIS 何时创建额外的工作进程?在我们实施 Web 园之前,我们应该了解哪些知识?

    答:在您创建应用程序池时,就会通知 IIS 6 创建一个工作进程,以传送指派给该应用程序池的 Web 站点、文件和文件夹的内容。您可以将应用程序池配置为启动多个,而非一个工作进程,这样可以提高可扩展性。这个功能的名为 Web 园,是小型的“Web 农场”。您无需使用多台计算机来传送相同的内容(Web 农场),而是可以使用一台计算机中的多个进程来传送相同的内容。

    在将 IIS 6 应用程序配置为 Web 园时,您只需在“应用程序池属性”的“性能”选项卡的“最大工作进程数”框中,设置一个大于 1 的工作进程数。如果这个值大于 1,每个请求都将启动一个新的工作进程实例,可启动的最多进程数为您所指定的最大工作进程数。后续的请求将以循环的方式发送至工作进程。

    Web 园在您的应用程序资源有限的情况下非常有用。例如,如果您到数据库的连接很慢,那么您可以使用多个工作进程来增加用户吞吐量,从而增加到数据库的连接数。

    尽管在有些情况下使用 Web 园的用处非常大,但是要注意,每个工作进程的会话信息都是唯一的。由于请求以循环的方式路由到应用程序池工作进程,因此 Web 园对于会话信息存储在进程中的应用程序作用可能不大。在少数情况下,让多个工作进程运行同一个应用程序会造成资源竞争。例如,如果所有工作进程都试图将信息记录到日志文件中,或是使用那些不是专用于多个并发访问的资源,那么可能出现资源竞争问题。

    如果不存在这些问题,那么 Web 园可能正是您所需的功能之一,而且其作用会非常大。

    这下我都无语了,杂办呢?这么好的功能不用,启不浪费。我要用Session,Session是存储在工作进程中的。Session老是丢失,无语中。。。。。。

    解决办法:修改web.config文件,将Session的配置从InProc中改成StateServer。不要以为这样改一下就Ok了,没那么简单吧。其实也挺简单的,就是要开启一个服务:运行->services.msc->asp.net状态服务->启动就一切Ok了。这样的话,我有一个问题一定要注意,asp.net网站,DLL文件重新编译后,传新网站的时候,Session会丢失。建议传新网站后,重启IIS。运行-》iisreset

  • 相关阅读:
    使用VMware 15 安装虚拟机和使用CentOS 8
    .Net工具类--表达式目录树解析DataReader和DataTable
    .Net 获取当前周是第几周
    使用Net Mail发送邮件
    ASP.NET Core 中的 Razor 文件编译
    Sql去重一些技巧
    手动实现一个简单的IOC容器
    Portswigger-web-security-academy:OAth authentication vulnerable
    Portswigger-web-security-academy:ssrf
    Portswigger-web-security-academy:os command injection
  • 原文地址:https://www.cnblogs.com/weaver1/p/2298224.html
Copyright © 2011-2022 走看看