From 0c251a546c67fc87661c00a7c89a9bb8f979c0fe Mon Sep 17 00:00:00 2001 From: Ubikuity Date: Wed, 25 Feb 2015 09:26:26 +0100 Subject: [PATCH] Fix SampleApp to make it work with VS2013+IIS Express or IIS7 --- SampleApp/Global.asax.cs | 11 ++++++++++- SampleApp/Web.config | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/SampleApp/Global.asax.cs b/SampleApp/Global.asax.cs index 0c140ca..d9af062 100644 --- a/SampleApp/Global.asax.cs +++ b/SampleApp/Global.asax.cs @@ -6,6 +6,15 @@ namespace SampleApp { public class Global : HttpApplication { + + static readonly HttpRequest InitialRequest; + + static Global() { + // Workaround to fix error "Request is not available in this context" with IIS7 or IIS Express + // http://sammyageil.com/post/Request-is-not-available-in-this-context-exception-in-Globalasaxs-Application_Start-IIS-7-Integrated-mode + InitialRequest = HttpContext.Current.Request; + } + protected void Application_Start(object sender, EventArgs e) { // First, initialize Quartz.NET as usual. In this sample app I'll configure Quartz.NET by code. var schedulerFactory = new StdSchedulerFactory(); @@ -16,7 +25,7 @@ protected void Application_Start(object sender, EventArgs e) { Setup.Scheduler = () => scheduler; // This adds an logger to the QuartzNetWebConsole. It's optional. - var partialQuartzConsoleUrl = string.Format("http://{0}:{1}/quartz/", Context.Request.Url.Host, Context.Request.Url.Port); + var partialQuartzConsoleUrl = string.Format("http://{0}:{1}/quartz/", InitialRequest.Url.Host, InitialRequest.Url.Port); Setup.Logger = new MemoryLogger(1000, partialQuartzConsoleUrl); // I'll add some global listeners diff --git a/SampleApp/Web.config b/SampleApp/Web.config index 817916f..b101e51 100644 --- a/SampleApp/Web.config +++ b/SampleApp/Web.config @@ -91,6 +91,7 @@ +