简体   繁体   English

可以以编程方式在.net中设置sessionState模式吗?

[英]is it possible to set sessionState mode programmatically in.net?

For ac# web site project that serves content for mobile phones i need to use sesion state. 对于为手机提供内容的ac#网站项目,我需要使用sesion状态。 Mobile browsing is abit tricky area, you cannot rely on cookies because some networks just removes them or some phones does not support them at all. 移动浏览是一个棘手的问题,您不能依赖Cookie,因为某些网络会删除它们,或者某些电话根本不支持它们。

.net's cookieless sessions perfect solution for me but they come with some cons. .net的无cookie会话对我来说是完美的解决方案,但它们也有一些缺点。 For example app in the start of session .net redirects user current page itself with AspxAutoDetectCookieSuppor=1 parameter in order to check if cookies supported. 例如,会话.net开始时的app使用AspxAutoDetectCookieSuppor = 1参数重定向用户当前页面本身,以检查是否支持cookie。

This is not ideal for me as every request will get redirected atleast once and search engines does not like this. 这对我来说并不理想,因为每个请求都会至少重定向一次,并且搜索引擎不喜欢这样。

My question is if there is any way setting up session state mode in global.asax or with http handler when a session started so i can control it's mode and set false for search engine bots 我的问题是,是否有任何方法可以在会话启动时在global.asax或http处理程序中设置会话状态模式,以便我可以控制其模式并为搜索引擎机器人设置false

您可以尝试检测浏览器代理(因为每个搜索引擎机器人都有它自己的代理版本,可能会很难做到),并对所有页面使用BasePage类,如果浏览器代理是搜索引擎,则将EnableSessionState设置为false。

As Jeff has talked about in his podcasts, you could set up a dedicated server for search engines and route their traffic to it. 正如Jeff在播客中谈到的那样,您可以为搜索引擎设置专用服务器,并将其流量路由到该服务器。 That way it can be configured correctly for Google/etc.., and be configured differently for everyone else. 这样就可以为Google / etc ..正确配置它,并为其他所有人进行不同的配置。

I know it's not the easiest solution from a management standpoint, but it's an option. 从管理的角度来看,我知道这不是最简单的解决方案,但这是一个选择。

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

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