0

我对 Windows 2012 上的 ASP.NET 4.5 会话有一个非常奇怪的问题

描述:会话工作正常。我浏览网站、登录、访问例如个人资料和使用会话的其他 aspx 页面。然后从一秒到另一秒,在任何 aspx 页面上,会话都会丢失,在每个 aspx 页面上。几秒钟后,会话又回来了。因此,如果我在问题出现之前登录,我会丢失会话值,几秒钟后它们又回来了。每个浏览器(IE、FF、Chrome)都会发生这种情况。我还没有尝试过使用 InProc、State Server、Appfabric,但都是一样的,所以必须对“顶级”上的 .net 会话处理或 IIS 做一些事情……不确定,但主要是,主观上我认为在会话“丢失”之前请求非常慢。疯了,他们“回来”之后……所以他们并没有真正迷路。

任何的想法 ?

更新

我添加了一些调试代码。看看登录,它最容易重现。这里是代码隐藏:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Response.Write("StepA/")
End Sub



Protected Sub btnSignin(ByVal sender As Object, ByVal e As EventArgs)

    Response.Write("Step0/")
    If System.Web.Security.Membership.ValidateUser(loginEmail.Value, loginPassword.Value) = True Then

        Response.Write("Step1/")

        FormsAuthentication.SetAuthCookie(loginEmail.Value, False)
        Response.Write("Step2/")

        Dim ui As New UserInfo
        Response.Write("Step3/")
        ui.InitUserInfo(loginEmail.Value)
        Response.Write("Step4/")

        If Request.UrlReferrer.OriginalString.Contains("Login.aspx") = True Then
            Response.Write("Step5/")
            Response.Redirect("/admin/Default.aspx")
        Else
            Response.Write("Step6/")
            Response.Redirect(Request.UrlReferrer.OriginalString)

        End If


    Else
        Response.Write("Step7/")
        loginfailed.Visible = True
    End If

End Sub

所以...运行一切正常,初始加载,打印出“stepA”。然后登录后Step0到5或6

然后,出于任何原因,会话“丢失”,上面的代码不会打印出步骤 0 到 6。看起来点击事件不会触发。嗯......但是,然后,重新启动 AppFabric 缓存,哦,奇怪......它可以工作,正如我之前写的......状态服务器也会发生同样的情况,然后重新启动 StateServer 解决了问题和 Inproc,重新启动 IIS 或应用程序解决了它。 ...

只是要清楚。此会话丢失或所有 aspx 页面上出现任何问题,而不仅仅是登录。至少使用会话的任何地方

4

1 回答 1

1

after a lot of reading, new relic monitoring etc i found the real problem and a working solution. the problem is related to the fact, that asp.net, until 4.5 block sessions in some scenarios (eg if you have iframes, updatepanel etc), until a page is fully loaded. if a user goes on another page on my side,and the session is blocked, it comes to the described results, waiting time for x seconds etc.

The solution, which works for me, x times better performance but resolved blocking problem:

I use Couchbase (www.couchbase.com) as cash and session "store", with this excellent session and cache provider for couchbase: https://github.com/evereq/couchbase-aspnet

Important here, related to the blocking probem is the config part: exclusiveAccess="false" for the session provider

2 problems i had, related to Win 8 Dev PC and Win 2012 server. On Win 2012 we need to replace a dll, described here:

For anyone interested this is a x64 version of a 'wrapper' for libtcmalloc. Just place it in your couchbase 'bin' directory and restart the couchbase service.

x64 version of the dll http://www.mediafire.com/?xc8nurnxjqr8klb

PS: Thanks to Chris Wundram for the hint!

On Win 8 this blog post describes well what to do:

http://blogs.southworks.net/mkrikorian/2013/02/06/installing-couchbase-under-windows-8/

as i said, after this, blocking problems gone and much better performance

于 2013-04-06T12:53:49.780 回答