private void InitializeSession() { HttpContext.Current = new HttpContext(workerRequest); HttpContext.Current.Items.Clear(); HttpSessionState session = (HttpSessionState)ReflectionHelper.Instantiate(typeof(HttpSessionState), new Type[] { typeof(IHttpSessionState) }, new FakeHttpSessionState()); HttpContext.Current.Items.Add("AspSession", session); }
private void InitializeSession() { HttpContext.Current = new HttpContext(workerRequest); HttpContext.Current.Items.Clear(); HttpSessionState session = (HttpSessionState)ReflectionHelper.Instantiate(typeof(HttpSessionState), new Type[] { typeof(IHttpSessionState) }, new FakeHttpSessionState()); HttpContext.Current.Items.Add("AspSession", session); HttpContext.Current.Request.Browser = new HttpBrowserCapabilities { Capabilities = new System.Collections.Generic.Dictionary <string, string> { { "majorversion", "8" }, { "browser", "IE" }, { "isMobileDevice", "false" } } }; }
void SetHttpRuntimeInternals() { //We cheat by using reflection. // get singleton property value HttpRuntime runtime = ReflectionHelper.GetStaticFieldValue <HttpRuntime>("_theRuntime", typeof(HttpRuntime)); // set app path property value ReflectionHelper.SetPrivateInstanceFieldValue("_appDomainAppPath", runtime, PhysicalApplicationPath); // set app virtual path property value string vpathTypeName = "System.Web.VirtualPath, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"; object virtualPath = ReflectionHelper.Instantiate(vpathTypeName, new Type[] { typeof(string) }, new object[] { ApplicationPath }); ReflectionHelper.SetPrivateInstanceFieldValue("_appDomainAppVPath", runtime, virtualPath); // set codegen dir property value ReflectionHelper.SetPrivateInstanceFieldValue("_codegenDir", runtime, PhysicalApplicationPath); HostingEnvironment environment = GetHostingEnvironment(); ReflectionHelper.SetPrivateInstanceFieldValue("_appPhysicalPath", environment, PhysicalApplicationPath); ReflectionHelper.SetPrivateInstanceFieldValue("_appVirtualPath", environment, virtualPath); ReflectionHelper.SetPrivateInstanceFieldValue("_configMapPath", environment, new ConfigMapPath(this)); }