/// <summary>
        /// Executes the handler within the given <paramref name="context"/>.
        /// </summary>
        /// <param name="context">The <see cref="IMansionWebContext"/> in which to execute the current request.</param>
        /// <param name="outputPipe">The <see cref="WebOutputPipe"/> to which the must should be written.</param>
        protected override void DoExecute(IMansionWebContext context, WebOutputPipe outputPipe)
        {
            // retrieve the resource
            var originalResourcePath = context.Request.RequestUrl.Path.Substring(Prefix.Length + 1);
            var resourcePath = new RelativeResourcePath(originalResourcePath, true);

            // set output pipe properties
            outputPipe.Response.ContentType = WebUtilities.GetMimeType(originalResourcePath);
            outputPipe.Encoding = Encoding.UTF8;

            // if the resource does not exist, send a 404
            if (!resourceService.Exists(context, resourcePath))
            {
                // send 404
                outputPipe.Response.StatusCode = HttpStatusCode.NotFound;
                outputPipe.Response.StatusDescription = "Not Found";
                return;
            }

            // merge all the resources
            foreach (var resource in resourceService.Get(context, resourcePath))
            {
                // parse the resource script
                var script = scriptService.Parse(context, resource);

                // execute the script and write the result back to the output pipe
                outputPipe.Writer.Write(script.Execute<string>(context));
            }

            // set expires header age
            outputPipe.Response.CacheSettings.Expires = DateTime.Now.AddYears(1);
        }
        /// <summary>
        /// Executes the handler within the given <paramref name="context"/>.
        /// </summary>
        /// <param name="context">The <see cref="IMansionWebContext"/> in which to execute the current request.</param>
        /// <param name="outputPipe">The <see cref="WebOutputPipe"/> to which the must should be written.</param>
        protected override void DoExecute(IMansionWebContext context, WebOutputPipe outputPipe)
        {
            // retrieve the resource
            var originalResourcePath = context.Request.RequestUrl.Path.Substring(Prefix.Length + 1);
            var resourcePath = new RelativeResourcePath(originalResourcePath, false);

            // set output pipe properties
            outputPipe.Response.ContentType = WebUtilities.GetMimeType(originalResourcePath);
            outputPipe.Encoding = Encoding.UTF8;

            // if the resource exist process it otherwise 404
            if (!resourceService.Exists(context, resourcePath))
            {
                // send 404
                outputPipe.Response.StatusCode = HttpStatusCode.NotFound;
                outputPipe.Response.StatusDescription = "Not Found";
                return;
            }

            // parse the resource script
            var resource = resourceService.GetSingle(context, resourcePath);

            // stream the file
            using (var reader = resource.OpenForReading())
                reader.RawStream.CopyTo(outputPipe.RawStream);

            // set expires header age
            outputPipe.Response.CacheSettings.Expires = DateTime.Now.AddYears(1);
        }
		/// <summary>
		/// Tries to load settings from the global settings file.
		/// </summary>
		/// <param name="context">The <see cref="MansionContext"/>.</param>
		private void TryLoadSettingsFromGlobal(IMansionContext context)
		{
			var globalResourcePath = new RelativeResourcePath(ResourceUtils.Combine("Global.xinclude"), false);

			// don't load settings when there is no settings file
			if (!applicationResourceService.Exists(context, globalResourcePath))
				return;

			using (var script = tagScriptService.Parse(context, applicationResourceService.GetSingle(context, globalResourcePath)))
			{
				script.Initialize(context);
				script.Execute(context);
			}
		}
        /// <summary>
        /// Executes the handler within the given <paramref name="context"/>.
        /// </summary>
        /// <param name="context">The <see cref="IMansionWebContext"/> in which to execute the current request.</param>
        /// <param name="outputPipe">The <see cref="WebOutputPipe"/> to which the must should be written.</param>
        protected override void DoExecute(IMansionWebContext context, WebOutputPipe outputPipe)
        {
            // always disable cache for backoffice users
            if (context.BackofficeUserState.IsAuthenticated)
                outputPipe.Response.CacheSettings.OutputCacheEnabled = false;

            // determine path to the script which to execute
            var scriptPath = new RelativeResourcePath(context.Request.RequestUrl.Path, false);

            // check if the request is to an actual script file, use the default script in that case
            if (!resourceService.Exists(context, scriptPath))
                scriptPath = context.IsBackoffice ? DefaultBackofficePath : DefaultFrontofficePath;

            // parse the script
            using (var script = scriptService.Parse(context, resourceService.GetSingle(context, scriptPath)))
            {
                script.Initialize(context);
                script.Execute(context);
            }
        }
		/// <summary>
		/// Tries to load settings from the environment specific settings file.
		/// </summary>
		/// <param name="context">The <see cref="MansionContext"/>.</param>
		private void TryLoadSettingsFromEnvironment(IMansionContext context)
		{
			var settingsResourcePath = new RelativeResourcePath(ResourceUtils.Combine("Settings", Environment.MachineName + ".xinclude"), false);

			// don't load settings when there is no settings file
			if (!applicationResourceService.Exists(context, settingsResourcePath))
				return;

			// load the settings
			using (var script = tagScriptService.Parse(context, applicationResourceService.GetSingle(context, settingsResourcePath)))
			{
				script.Initialize(context);
				script.Execute(context);
			}
		}