/// <summary> /// Creates an instance of HttpRuntime and assigns it (using magic) to the singleton instance of HttpRuntime. /// Ensure that the returned value is disposed at the end of the test. /// </summary> /// <returns>Returns an IDisposable that restores the original HttpRuntime.</returns> public static IDisposable CreateHttpRuntime(string appVPath, string appPath = null) { var runtime = new HttpRuntime(); var appDomainAppVPathField = typeof(HttpRuntime).GetField("_appDomainAppVPath", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance); appDomainAppVPathField.SetValue(runtime, CreateVirtualPath(appVPath)); if (appPath != null) { var appDomainAppPathField = typeof(HttpRuntime).GetField("_appDomainAppPath", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance); appDomainAppPathField.SetValue(runtime, Path.GetFullPath(appPath)); } GetTheRuntime().SetValue(null, runtime); var appDomainIdField = typeof(HttpRuntime).GetField("_appDomainId", BindingFlags.NonPublic | BindingFlags.Instance); appDomainIdField.SetValue(runtime, "test"); return new DisposableAction(RestoreHttpRuntime); }
/// <summary> /// Try to Restart the Application /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void RestartAppClick([NotNull] object sender, [NotNull] EventArgs e) { HttpRuntime.UnloadAppDomain(); }
public IHttpActionResult Restart() { HttpRuntime.UnloadAppDomain(); return(StatusCode(HttpStatusCode.NoContent)); }
public void RestartFull() { HttpRuntime.UnloadAppDomain(); echoRedirect(lang("restartDone"), ctx.url.SiteAndAppPath); }
public void ProcessRequest(string page, object o) { HttpRuntime.ProcessRequest(new WorkerRequest(page, null, Console.Out, o)); }
internal SecurityPolicyConfig(SecurityPolicyConfig parent, XmlNode node, String strFile) { if (parent != null) { _PolicyFiles = (Hashtable)parent.PolicyFiles.Clone(); } else { _PolicyFiles = new Hashtable(); } // CONSIDER: Path.GetDirectoryName() String strDir = strFile.Substring(0, strFile.LastIndexOf('\\') + 1); foreach (XmlNode child in node.ChildNodes) { //////////////////////////////////////////////////////////// // Step 1: For each child if (HandlerBase.IsIgnorableAlsoCheckForNonElement(child)) { continue; } if (child.Name != "trustLevel") { HandlerBase.ThrowUnrecognizedElement(child); } string name = null; string file = null; XmlNode nameAttribute = HandlerBase.GetAndRemoveRequiredStringAttribute(child, "name", ref name); HandlerBase.GetAndRemoveRequiredStringAttribute(child, "policyFile", ref file); HandlerBase.CheckForUnrecognizedAttributes(child); HandlerBase.CheckForChildNodes(child); bool fAppend = true; // Append dir to filename if (file.Length > 1) { char c1 = file[1]; char c0 = file[0]; if (c1 == ':') // Absolute file path { fAppend = false; } else if (c0 == '\\' && c1 == '\\') // UNC file path { fAppend = false; } } String strTemp; if (fAppend) { strTemp = strDir + file; } else { strTemp = file; } if (_PolicyFiles.Contains(name)) { throw new ConfigurationException( HttpRuntime.FormatResourceString(SR.Security_policy_level_already_defined, name), nameAttribute); } _PolicyFiles.Add(name, strTemp); } HandlerBase.CheckForUnrecognizedAttributes(node); }
public override void SendResponseFromFile(IntPtr handle, long offset, long length) { /* Not needed by state application */ throw new NotSupportedException(HttpRuntime.FormatResourceString(SR.Not_supported)); }
public void UnloadAppDomain_PermitOnly_Unmanaged () { HttpRuntime.UnloadAppDomain (); }
public ViewResult ExternalLogins(FormCollection collection) { SaveFormValuesToSettings(collection); HttpRuntime.UnloadAppDomain(); return(View(_settingsManager.Current)); }
public static void UnloadAppDomain_OnLoad(Page p) { HttpRuntime.UnloadAppDomain(); }
//called once for the lifetime of the app domain protected void Application_Start() { AppDomainException = null; GlobalConfiguration.Configure(WebApiConfig.Register); //allow xml serialization //GlobalConfiguration.Configuration.Formatters.XmlFormatter.UseXmlSerializer = true; // ServicePointManager setup ServicePointManager.UseNagleAlgorithm = false; ServicePointManager.Expect100Continue = false; ServicePointManager.DefaultConnectionLimit = int.MaxValue; ServicePointManager.EnableDnsRoundRobin = true; //ServicePointManager.ReusePort = true; try { //initialize SupportLock.SetLicense(); DicomEngine.Startup(); DicomNet.Startup(); //Unity dependency injection container var unity = new UnityContainer(); //register types //controllers that should be injectable unity.RegisterType <AuthController>(); unity.RegisterType <AuditController>(); unity.RegisterType <TemplateController>(); unity.RegisterType <StoreController>(); unity.RegisterType <PatientController>(); unity.RegisterType <PatientAccessRightsController>(); unity.RegisterType <PACSRetrieveController>(); unity.RegisterType <PacsQueryController>(); unity.RegisterType <OptionsController>(); unity.RegisterType <MonitorCalibrationController>(); unity.RegisterType <ExportController>(); unity.RegisterType <RetrieveController>(); unity.RegisterType <QueryController>(); unity.RegisterType <ThreeDController>(); unity.RegisterType <AutoController>(); //injectable types unity.RegisterType <AddinsFactory>(); //injectable types/base unity.RegisterType <IAuthHandler, AuthHandler>(); unity.RegisterType <IAuditHandler, AuditHandler>(); unity.RegisterType <ITemplateHandler, TemplateHandler>(); unity.RegisterType <IStoreHandler, StoreHandler>(); unity.RegisterType <IPatientHandler, PatientHandler>(); unity.RegisterType <IPatientAccessRightsHandler, PatientAccessRightsHandler>(); unity.RegisterType <IOptionsHandler, OptionsHandler>(); unity.RegisterType <IMonitorCalibrationHandler, MonitorCalibrationHandler>(); //unity.RegisterType<IStreamExportHandler, StreamExportHandler>(); unity.RegisterType <IHashingProvider, HashingProvider>(); unity.RegisterType <IExportHandler, ExportHandler>(); unity.RegisterType <IRetrieveHandler, RetrieveHandler>("local"); unity.RegisterType <IRetrieveHandler, WadoRetrieveHandler>("wado"); unity.RegisterType <IQueryHandler, QueryHandler>("local"); unity.RegisterType <IQueryHandler, WadoQueryHandler>("wado"); unity.RegisterType <IThreeDHandler, ThreeDHandler>(); unity.RegisterType <IPacsQueryHandler, PacsQueryHandler>("pacsquery"); unity.RegisterType <IPacsQueryHandler, WadoAsPacsQueryHandler>("wadoaspacsquery"); unity.RegisterType <IPacsRetrieveHandler, PacsRetrieveHandler>("pacsretrieve"); unity.RegisterType <IPacsRetrieveHandler, WadoAsPacsRetrieveHandler>("wadoaspacsretrieve"); unity.RegisterType <IAutoHandler, AutoHandler>(); { //register singletons CreateSingletons(); unity.RegisterInstance <Lazy <IMessagesBus> >(_messageBus, new ExternallyControlledLifetimeManager()); unity.RegisterInstance <Lazy <IStorageDataAccessAgent3> >(_storageAgent, new ExternallyControlledLifetimeManager()); unity.RegisterInstance <Lazy <ILoggingDataAccessAgent> >(_loggingAgent, new ExternallyControlledLifetimeManager()); unity.RegisterInstance <Lazy <IUserManagementDataAccessAgent4> >(_userManagementDataAccessAgent, new ExternallyControlledLifetimeManager()); unity.RegisterInstance <Lazy <IPermissionManagementDataAccessAgent2> >(_permissionManagementDataAccessAgent, new ExternallyControlledLifetimeManager()); unity.RegisterInstance <Lazy <IOptionsDataAccessAgent> >(_optionsDataAccessAgent, new ExternallyControlledLifetimeManager()); unity.RegisterInstance <Lazy <IPatientRightsDataAccessAgent> >(_patientRightsDataAccess, new ExternallyControlledLifetimeManager()); unity.RegisterInstance <Lazy <IDownloadJobsDataAccessAgent> >(_downloadJobsDataAccessAgent, new ExternallyControlledLifetimeManager()); unity.RegisterInstance <Lazy <IAuthorizedStorageDataAccessAgent2> >(_authorizedStorageDataAccessAgent, new ExternallyControlledLifetimeManager()); unity.RegisterInstance <Lazy <IMonitorCalibrationDataAccessAgent> >(_monitorCalibrationDataAccessAgent, new ExternallyControlledLifetimeManager()); unity.RegisterInstance <Lazy <ITemplateDataAccessAgent> >(_templateDataAccessAgent, new ExternallyControlledLifetimeManager()); unity.RegisterInstance <Lazy <IExternalStoreDataAccessAgent> >(_externalStoreAgent, new ExternallyControlledLifetimeManager()); unity.RegisterInstance <Lazy <Leadtools.Dicom.Imaging.IDataCacheProvider> >(_dataCache, new ExternallyControlledLifetimeManager()); unity.RegisterInstance <Lazy <ConnectionSettings> >(_connectionSettings, new ExternallyControlledLifetimeManager()); } //set default dependency resolver to Unity (with the wrapper) GlobalConfiguration.Configuration.DependencyResolver = new IoCContainer(unity); //caching workers LTCachingCtrl.QeueuWorkers(); } catch (ServiceSetupException ex) { AppDomainException = ex; //handle on first request } catch (Exception) { HttpRuntime.UnloadAppDomain(); throw; } }
public void CloudApplicationBeginRequest(object sender, EventArgs e, TheBaseApplication pApplication) { StartTheSite(pApplication, Context); if (TheBaseAssets.CryptoLoadMessage != null) { Response.Write($"...Cloud security initializing failed: {TheBaseAssets.CryptoLoadMessage}"); Response.End(); return; } if (TheBaseAssets.MyServiceHostInfo == null || !TheBaseAssets.MyServiceHostInfo.AllSystemsReady) //&& Request.Url.ToString().EndsWith("cdestatus.aspx", StringComparison.OrdinalIgnoreCase)) { Response.Write("...Cloud initializing, please wait"); Response.End(); return; } if (Request.Url.ToString().EndsWith("cdeRestart.aspx") && IsTokenValid(Request)) { HttpRuntime.UnloadAppDomain(); return; } if (Request.Url.ToString().EndsWith("ashx", StringComparison.CurrentCultureIgnoreCase)) { return; } if (ExpiredText != null) { Response.Write(ExpiredText); Response.End(); return; } if (Context.Request.Url.Scheme == "http" && TheBaseAssets.MyServiceHostInfo.MyStationPort == 443) { Response.Write( $"<html><head><meta http-equiv=\"refresh\" content=\"0; url={TheBaseAssets.MyServiceHostInfo.MyStationURL}{Context.Request.Url.PathAndQuery}\"></head></html>"); Response.End(); return; } TheRequestData tReq = new TheRequestData { RequestUri = Request.Url, HttpMethod = HttpContext.Current.Request.HttpMethod, UserAgent = HttpContext.Current.Request.UserAgent, ServerTags = TheCommonUtils.cdeNameValueToDirectory(HttpContext.Current.Request.ServerVariables), Header = TheCommonUtils.cdeNameValueToDirectory(HttpContext.Current.Request.Headers), ResponseMimeType = Request.ContentType, //ClientCert = HttpContext.Current.Request.ClientCertificate, ClientCert = HttpContext.Current.Request.ClientCertificate?.Count > 0 ? new System.Security.Cryptography.X509Certificates.X509Certificate2(HttpContext.Current.Request.ClientCertificate?.Certificate):null, //Verified that this works with no private key. Since C-DEngineCloud only works on Windows in IIS and MUST run as Administrator there is no linux check required here }; if (TheCommCore.MyHttpService != null && TheBaseAssets.MyServiceHostInfo.ClientCertificateUsage > 1) //If CDE requires a certificate, terminate all incoming requests before any processing { var err = TheCommCore.MyHttpService.ValidateCertificateRoot(tReq); if (TheBaseAssets.MyServiceHostInfo.DisableNMI && !string.IsNullOrEmpty(err)) { Response.StatusCode = (int)eHttpStatusCode.AccessDenied; CompleteRequest(); return; } } using (MemoryStream ms = new MemoryStream()) { Request.InputStream.CopyTo(ms); tReq.PostData = ms.ToArray(); } tReq.PostDataLength = tReq.PostData.Length; if (Request.Browser != null) { tReq.BrowserType = Request.Browser.Browser + " " + Request.Browser.Version; tReq.BrowserPlatform = Request.Browser.Platform; tReq.BrowserScreenWidth = Request.Browser.ScreenPixelsWidth; } //TheHttpService.ProcessGlobalAsax(Request, Response); if (TheCommCore.MyHttpService != null && TheCommCore.MyHttpService.cdeProcessPost(tReq)) { if (tReq.StatusCode != 0) { Response.StatusCode = tReq.StatusCode; AddCookiesToHeader(tReq); Response.AddHeader("Cache-Control", tReq.AllowCaching ? "max-age=60, public" : "no-cache"); if (tReq.StatusCode > 300 && tReq.StatusCode < 400 && tReq.Header != null) { Response.AddHeader("Location", tReq.Header.cdeSafeGetValue("Location")); } if (tReq.ResponseBuffer != null) { Response.AddHeader("cdeDeviceID", TheBaseAssets.MyServiceHostInfo.MyDeviceInfo.DeviceID.ToString()); Response.ContentType = tReq.ResponseMimeType; Response.BinaryWrite(tReq.ResponseBuffer); CompleteRequest(); } } } }
protected void Page_Load(object sender, EventArgs e) { HttpRuntime.UnloadAppDomain(); }
public void ProcessRequest() { uWSGIRequest ur = new uWSGIRequest(); HttpRuntime.ProcessRequest(ur); }
/// <summary> /// Unload app domain<br/> /// 卸载AppDomain<br/> /// </summary> public void StopWebsite() { // Owin didn't provide interface for stopping website // Just use same method from Asp.Net HttpRuntime.UnloadAppDomain(); }
public void UnloadAppDomain_Deny_Unmanaged () { HttpRuntime.UnloadAppDomain (); }
public void ProcessRequest(String p_aspx) { HttpRuntime.ProcessRequest(new SimpleWorkerRequest(p_aspx, null, Console.Out)); }
public override long GetBytesRead() { /* State web doesn't support partial reads */ throw new NotSupportedException(HttpRuntime.FormatResourceString(SR.Not_supported)); }
protected void btnResetApp_Click(object sender, EventArgs e) { HttpRuntime.UnloadAppDomain(); }
/// <summary> /// Save the Updated Xml File. /// </summary> private void SaveLanguageFile() { this.translations = RemoveDuplicateSections(this.translations); new XmlDocument(); var xwSettings = new XmlWriterSettings { Encoding = Encoding.UTF8, OmitXmlDeclaration = false, Indent = true, IndentChars = " " }; XmlWriter xw = XmlWriter.Create(Path.Combine(this.sLangPath, this.sXmlFile), xwSettings); xw.WriteStartDocument(); // <Resources> xw.WriteStartElement("Resources"); foreach (string key in this.ResourcesNamespaces.Keys) { xw.WriteAttributeString("xmlns", key, null, this.ResourcesNamespaces[key]); } foreach (string key in this.ResourcesAttributes.Keys) { xw.WriteAttributeString(key, this.ResourcesAttributes[key]); } var currentPageName = string.Empty; foreach (Translation trans in this.translations.OrderBy(t => t.PageName).ThenBy(t => t.ResourceName)) { // <page></page> if (!trans.PageName.Equals(currentPageName, StringComparison.OrdinalIgnoreCase)) { if (currentPageName.IsSet()) { xw.WriteFullEndElement(); } currentPageName = trans.PageName; xw.WriteStartElement("page"); xw.WriteAttributeString("name", currentPageName); } xw.WriteStartElement("Resource"); xw.WriteAttributeString("tag", trans.ResourceName); xw.WriteString(trans.LocalizedValue); xw.WriteFullEndElement(); } // final </page> if (currentPageName.IsSet()) { xw.WriteFullEndElement(); } // </Resources> xw.WriteFullEndElement(); xw.WriteEndDocument(); xw.Close(); if (General.GetCurrentTrustLevel() >= AspNetHostingPermissionLevel.High) { HttpRuntime.UnloadAppDomain(); } }
/*internal void StartAssemblyChangeMonitor() * { * var watcher = new FileSystemWatcher(AppDomain.CurrentDomain.SetupInformation.PrivateBinPath, "*.dll"); * watcher.IncludeSubdirectories = false; * * watcher.Changed += (sender, e) => * { * _server.SignalDomainReload(HostingEnvironment.ApplicationHost.GetVirtualPath()); * }; * * watcher.Created += (sender, e) => * { * _server.SignalDomainReload(HostingEnvironment.ApplicationHost.GetVirtualPath()); * }; * * watcher.Deleted += (sender, e) => * { * _server.SignalDomainReload(HostingEnvironment.ApplicationHost.GetVirtualPath()); * }; * * watcher.Renamed += (sender, e) => * { * _server.SignalDomainReload(HostingEnvironment.ApplicationHost.GetVirtualPath()); * }; * * watcher.EnableRaisingEvents = true; * }*/ internal void UnloadDomain() { HttpRuntime.UnloadAppDomain(); //AppDomain.Unload(AppDomain.CurrentDomain); }
public void SendRequest(AspNetRequestData RequestData) { Debug.WriteLine("Bin:" + HttpRuntime.BinDirectory); Debug.WriteLine("AppPath:" + HttpRuntime.AppDomainAppPath); HttpRuntime.ProcessRequest(new AspNetRequest(RequestData)); }
internal override void ProcessDirective(string directiveName, IDictionary directive) { if (string.Compare(directiveName, "outputcache", true, CultureInfo.InvariantCulture) == 0) { // Make sure the outputcache directive was not already specified if (_outputCacheDirective != null) { throw new HttpException( HttpRuntime.FormatResourceString(SR.Only_one_directive_allowed, directiveName)); } ProcessOutputCacheDirective(directiveName, directive); _outputCacheDirective = directive; } else if (string.Compare(directiveName, "register", true, CultureInfo.InvariantCulture) == 0) { // Register directive // Optionally, allow an assembly, which is used by the designer string assemblyName = Util.GetAndRemoveNonEmptyAttribute(directive, "assembly"); Assembly assembly = null; if (assemblyName != null) { assembly = AddAssemblyDependency(assemblyName); if (assembly == null) { // It should never be null at runtime, since it throws Debug.Assert(FInDesigner, "FInDesigner"); // Just ignore the directive (ASURT 100454) return; } } // Get the tagprefix, which is required string prefix = Util.GetAndRemoveNonEmptyIdentifierAttribute(directive, "tagprefix"); if (prefix == null) { throw new HttpException(HttpRuntime.FormatResourceString( SR.Missing_attr, "tagprefix")); } string tagName = Util.GetAndRemoveNonEmptyIdentifierAttribute(directive, "tagname"); string src = Util.GetAndRemoveNonEmptyAttribute(directive, "src"); string ns = Util.GetAndRemoveNonEmptyNoSpaceAttribute(directive, "namespace"); if (tagName != null) { // If tagname was specified, 'src' is required if (src == null) { throw new HttpException(HttpRuntime.FormatResourceString(SR.Missing_attr, "src")); } EnsureNullAttribute("namespace", ns); } else { // If tagname was NOT specified, 'namespace' is required if (ns == null) { throw new HttpException(HttpRuntime.FormatResourceString(SR.Missing_attr, "namespace")); } // Assembly is also required (ASURT 61326) if (assembly == null) { throw new HttpException(HttpRuntime.FormatResourceString(SR.Missing_attr, "assembly")); } EnsureNullAttribute("src", src); } // If there are some attributes left, fail Util.CheckUnknownDirectiveAttributes(directiveName, directive); // Is it a single tag to .aspx file mapping? if (tagName != null) { // Compile it into a Type Type type = GetUserControlType(src); // Register the new tag, including its prefix RootBuilder.RegisterTag(prefix + ":" + tagName, type); return; } AddImportEntry(ns); // If there is a prefix, register the namespace to allow tags with // that prefix to be created. RootBuilder.RegisterTagPrefix(prefix, ns, assembly); } else if (string.Compare(directiveName, "reference", true, CultureInfo.InvariantCulture) == 0) { string page = Util.GetAndRemoveNonEmptyNoSpaceAttribute(directive, "page"); string control = Util.GetAndRemoveNonEmptyNoSpaceAttribute(directive, "control"); // If neither or both are specified, fail if ((page == null) == (control == null)) { throw new HttpException(HttpRuntime.FormatResourceString(SR.Invalid_reference_directive)); } if (page != null) { GetReferencedPageType(page); } if (control != null) { GetUserControlType(control); } // If there are some attributes left, fail Util.CheckUnknownDirectiveAttributes(directiveName, directive); } else { base.ProcessDirective(directiveName, directive); } }
private void ThrowNotSupportedException() { throw new HttpException(HttpRuntime.FormatResourceString(SR.Control_does_not_allow_children, Owner.GetType().ToString())); }
public void Close_Deny_Unmanaged () { HttpRuntime.Close (); }
public static void InitiateShutdown() { HttpRuntime.UnloadAppDomain(); }
public void Close_PermitOnly_Unmanaged () { HttpRuntime.Close (); }
public static void RestartApplication() { HttpRuntime.Close(); }
public void ProcessRequest_Deny_Medium () { HttpRuntime.ProcessRequest (null); }
public void ProcessRequest_PermitOnly_Medium () { HttpRuntime.ProcessRequest (null); }
static ProcessHostConfigUtils() { HttpRuntime.ForceStaticInit(); }