Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text.RegularExpressions;
- using System.Web;
- namespace iPaper.Web.ArrCookieRestorer
- {
- public class ArrCookieRestorer : IHttpModule
- {
- public void Dispose()
- { }
- public void Init(HttpApplication context)
- {
- context.BeginRequest += context_BeginRequest;
- }
- private void context_BeginRequest(object sender, EventArgs e)
- {
- try
- {
- HttpContext context = HttpContext.Current;
- string serverHash = context.Request.QueryString["ARRIPARRAffinity"];
- if (serverHash != null)
- {
- string cookieHeader = context.Request.Headers["Cookie"];
- if (cookieHeader != null)
- {
- if (cookieHeader.Contains("IPARRAffinity="))
- cookieHeader = Regex.Replace(cookieHeader, "IPARRAffinity=[0-9a-f]+;?", "IPARRAffinity=" + serverHash + ";");
- else
- cookieHeader += "; IPARRAffinity=" + serverHash;
- context.Request.Headers["Cookie"] = cookieHeader;
- }
- else
- context.Request.Headers.Add("Cookie", "IPARRAffinity=" + serverHash);
- }
- }
- catch
- { }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement