/// <summary> /// Dispose(bool disposing) executes in two distinct scenarios. If disposing /// equals true, the method has been called directly or indirectly by a user's /// code. Managed and unmanaged resources can be disposed. If disposing equals /// false, the method has been called by the runtime from inside the finalizer /// and you should not reference other objects. Only unmanaged resources can /// be disposed. /// </summary> protected virtual void Dispose(bool disposing) { // Check to see if Dispose has already been called. if (!this._disposed) { // Note disposing has been done. _disposed = true; // If disposing equals true, dispose all managed // and unmanaged resources. if (disposing) { if (_applicationHost != null) { _applicationHost.Dispose(); } } // Call the appropriate methods to clean up // unmanaged resources here. _host = null; _applicationHost = null; _lockObject = null; } }
/// <summary> /// Process the request. /// </summary> /// <param name="page">The page to load.</param> /// <param name="request">The current http request.</param> /// <param name="streamWriter">The output stream writer.</param> public void ProcessRequest(string page, Nequeo.Net.Http.HttpRequest request, System.IO.StreamWriter streamWriter) { lock (_lockObject) { try { // Execute the host. _host.ProcessRequest(page, streamWriter, (String.IsNullOrEmpty(request.Url.Query) ? null : request.Url.Query)); } catch (System.Runtime.Remoting.RemotingException) { // Create a new host instance when this one is released. _host = null; // Create the application host. CreateApplicationHost(); System.Threading.Thread.Sleep(400); try { // Execute the host. _host.ProcessRequest(page, streamWriter, (String.IsNullOrEmpty(request.Url.Query) ? null : request.Url.Query)); } catch { } } } }
/// <summary> /// Process the request. /// </summary> /// <param name="virtualDir">The virtual path to the application directory; for example, "/app".</param> /// <param name="physicalDir">The physical path to the application directory; for example, "c:\app".</param> /// <param name="page">The page to be requested (or the virtual path to the page, relative to the application directory).</param> /// <param name="output">A System.IO.TextWriter that captures output from the response.</param> /// <param name="query">The text of the query string.</param> /// <param name="processDefaultHttpHeaders">True if the http runtime process request is executed; else false.</param> /// <param name="configurationFile">The application configuration file (e.g. "web.config").</param> public virtual void ProcessRequest(string virtualDir, string physicalDir, string page, TextWriter output, string query = null, bool processDefaultHttpHeaders = true, string configurationFile = null) { // Execute the request. using (ApplicationHost applicationHost = new ApplicationHost()) { Nequeo.Web.Hosting.Host host = (Nequeo.Web.Hosting.Host)applicationHost.CreateApplicationHost(typeof(Nequeo.Web.Hosting.Host), virtualDir, physicalDir, configurationFile); host.ProcessRequest(page, output, query, processDefaultHttpHeaders); } }
/// <summary> /// Create the application host. /// </summary> public void CreateApplicationHost() { lock (_lockObject) { // If null. if (_host == null) { // Create the application host. _host = (Nequeo.Web.Hosting.Host)_applicationHost.CreateApplicationHost(typeof(Nequeo.Web.Hosting.Host), _virtualDir, _basePath, configurationFile: _configurationFile); } } }