1: private bool getIsCookielessSessionState()
2: {
3: object untypedSessionState = ConfigurationManager.GetSection("system.web/sessionState");
4: try
5: {
6: if (untypedSessionState != null)
7: {
8: System.Web.Configuration.SessionStateSection section =
9: (System.Web.Configuration.SessionStateSection)untypedSessionState;
10:
11: return section.Cookieless == HttpCookieMode.UseUri;
12: }
13: }
14: catch
15: {
16: return false;
17: }
18:
19: return false;
20: }
21:
22: private void processCookielessSessionId(HttpApplication app)
23: {
24: //Tratamiento para las sesiones cookieless
25: string parameterSessionId = "SessionId";
26: string url = app.Request.RawUrl;
27: int indexOfSessionId = url.IndexOf(parameterSessionId, StringComparison.CurrentCultureIgnoreCase);
28:
29: if (indexOfSessionId >= 0)
30: {
31: string sessionId = url.Substring(indexOfSessionId + parameterSessionId.Length + 1);
32: if (sessionId.IndexOf("&") >= 0)
33: sessionId = sessionId.Substring(0, sessionId.IndexOf("&"));
34:
35: if (sessionId.Length > 0)
36: {
37: url = url.Replace(app.Request.ApplicationPath, String.Empty);
38: url = url.Replace(parameterSessionId + "=" + sessionId, String.Empty);
39:
40: string newUrl = app.Request.ApplicationPath + "/" + sessionId + "/" + url;
41:
42: //Estandarizamos la url
43: newUrl = newUrl.Replace("?&", "?");
44: newUrl = newUrl.Replace("//", "/");
45:
46: if (newUrl[newUrl.Length - 1] == '?')
47: newUrl = newUrl.Remove(newUrl.Length - 1);
48: if (newUrl[newUrl.Length - 1] == '&')
49: newUrl = newUrl.Remove(newUrl.Length - 1);
50:
51: //Realizamos un redirect
52: app.Response.Redirect(newUrl);
53: }
54: }
55: }