简体   繁体   English

IE10和Windows 8以及ASP.NET MVC(IIS 7)

[英]IE10 and Windows 8 and ASP.NET MVC (IIS 7)

I'm having a very interesting, but frustrating issue. 我有一个非常有趣但令人沮丧的问题。 I have an MVC 4 site running with standard ASP.NET Authentication. 我有一个运行标准ASP.NET身份验证的MVC 4站点。

In and only in the combination of IE 10 on Windows 8, when I traverse my site and navigate to an http url from an https url (both on the same site), it is generating a different asp.net_sessionid value. 在Windows 8上的IE 10组合中,当我遍历我的站点并从https url(同一站点上)导航到http url时,它会生成不同的asp.net_sessionid值。 In every other browser/OS combo I have tried, this does not appear to be an issue. 在我尝试的其他所有浏览器/操作系统组合中,这似乎不是问题。

I have searched high and low and while I certainly have found people experiencing various authentication issues (usually regarding IIS7 not recognizing IE10 as a browser), I have not found anyone else claiming to have experienced this exact issue. 我搜索过高低,虽然我发现人们遇到了各种身份验证问题(通常是关于IIS7没有将IE10识别为浏览器),但我没有发现其他人声称遇到过这个问题。 More concerning, I published an 'out of the box' MVC template project and it has the same issue. 更多的是,我发布了一个“开箱即用”的MVC模板项目,它有同样的问题。 I can't possibly be the only one who has run across this problem (so I hope). 我不可能是遇到这个问题的唯一一个人(我希望如此)。

Anyone else run into this? 其他人遇到这个? Or maybe even just have some suggestions? 或者甚至只是提出一些建议?

Thanks 谢谢

UPDATE UPDATE

Okay, so there is one more important aspect. 好的,还有一个更重要的方面。 I am running this on a load balanced environment. 我在负载均衡的环境中运行它。 If I push the apps to a single server and test, I have no issues. 如果我将应用程序推送到单个服务器并进行测试,我就没有问题。

You mention that you have had this problem in a load balanced environment, right? 你提到你在负载均衡的环境中遇到了这个问题,对吗? I assume you are using the default "In Proc" method of storing session data. 我假设您使用默认的“In Proc”方法存储会话数据。 If that is the case, then I think I know what could be happening. 如果是这样,那么我想我知道会发生什么。 (for the sake of argument, I will assume 2 servers, but It doesn't really matter if you have more) (为了争论,我将假设2台服务器,但如果你有更多服务器并不重要)

You are being sent to ServerA and a session is created. 您将被发送到ServerA并创建会话。 Because this is In Process ServerB has no idea about it. 因为这是In Process ServerB不知道它。 Eventually (and how that happens is a matter of how your load balancer is set up. Sticky session? Cookies? Round robin?) you will be sent to ServerB. 最终(以及如何发生这种情况取决于你的负载均衡器是如何设置的。粘性会话?Cookies?循环?)你将被发送到ServerB。 Because that server had no idea you already have a session; 因为那个服务器不知道你已经有了会话; a new one is created and you are given a new session ID. 创建一个新的,并为您提供一个新的会话ID。

So why is it happening under your exact repro steps? 那么为什么它会在您的确切重复步骤下发生? Well, my hunch is that given enough time and load, you would see it just navigating from /page1 to /page2. 好吧,我的预感是,如果有足够的时间和负载,你会看到它只是从/ page1导航到/ page2。 Again - this depends on how your load balancer is setup, but it could be that since you are changing protocol that triggers something and you are sent to the another server in the pool. 再次 - 这取决于您的负载均衡器的设置方式,但可能是因为您正在更改触发某些内容的协议,并且您将被发送到池中的另一台服务器。

How can you fix it? 你怎么解决它?
To start, make sure you have the same machine key in their machine.config. 首先,确保他们的machine.config中有相同的机器密钥。 If you don't have access to that I think it will work in the web.config, but I haven't tried it. 如果您没有访问权限,我认为它可以在web.config中运行,但我还没有尝试过。

Now, set up another way to store session state. 现在,设置另一种存储会话状态的方法。 In Sql Server perhaps or MySql or Postgres or wherever. 在Sql Server中或者MySql或Postgres或者任何地方。 If you have SQL Server that will be the easiest since the driver is built it, but if you have another datastore you will either need to build or find a library that will do it. 如果您的SQL Server是最简单的,因为驱动程序是由它构建的,但是如果您有另一个数据存储区,则需要构建或找到可以执行此操作的库。 I worked on a project where we used Postgres to store session state. 我参与了一个项目,我们使用Postgres来存储会话状态。

We used npgsql as the driver to conenct to the server, and built our own PgsqlSessionProvider:SessionStateStoreProviderBase and hooking it up is actually really easy 我们使用npgsql作为连接到服务器的驱动程序,并构建了我们自己的PgsqlSessionProvider:SessionStateStoreProviderBase并将其挂起实际上非常简单

<sessionState mode="Custom" customProvider="PgsqlSessionProvider">
  <providers>
    <add name="PgsqlSessionProvider" type="My.namespace.PgsqlSessionStateStore" connectionStringName="connectionStringName" writeExceptionsToEventLog="true" />
  </providers>
</sessionState>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM