public class Global : System.Web.HttpApplication
...{
protected void Application_Start(object sender, EventArgs e)
...{
System.Runtime.Remoting.RemotingConfiguration.Configure(Server.MapPath(HttpContext.Current.Request.ApplicationPath + "/web.config"), false);
Application["helper"] = new Helper();
string password = "";
IntPtr accessToken = new IntPtr(0);
SimpleCrypto.PasswordDecrypt(ConfigurationManager.AppSettings["UPLOAD_PASSWD"], out password);
if (NetworkSecurity.LogonAndGetToken(ConfigurationManager.AppSettings["UPLOAD_SITE"],
ConfigurationManager.AppSettings["UPLOAD_USER"], password,
ConfigurationManager.AppSettings["UPLOAD_NETWORK_LogonType"], ConfigurationManager.AppSettings["UPLOAD_NETWORK_LogonProvider"],
ref accessToken) == false)
...{
throw new Exception("Logon Failed");
}
password = "";
Application.Add("AccessToken", accessToken);
HttpContext.Current.User = new WindowsPrincipal(new WindowsIdentity((IntPtr)Application["AccessToken"]));
(HttpContext.Current.User.Identity as WindowsIdentity).Impersonate();
FileStream fs = new FileStream(ConfigurationManager.AppSettings["UPLOADSGFT"], FileMode.Open, FileAccess.Read);
StreamReader st = new StreamReader(fs, System.Text.Encoding.Default);
string word;
Dictionary<string, string> postFilter = new Dictionary<string, string>();
while ((word = st.ReadLine()) != null)
...{
if (!word.Trim().StartsWith("//") && !postFilter.ContainsKey(word.Trim().ToLower()))
postFilter.Add(word.Trim().ToLower(), string.Empty);
}
st.Close();
Application.Add("FilterText", postFilter);
}
protected void Application_End(object sender, EventArgs e)
...{
NetworkSecurity.CloseToken((IntPtr)Application["AccessToken"]);
Application.Clear();
}
}