Skip to content

Commit

Permalink
Fix SampleApp to make it work with VS2013+IIS Express or IIS7
Browse files Browse the repository at this point in the history
  • Loading branch information
ubikuity committed Feb 25, 2015
1 parent 9f96368 commit 0c251a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion SampleApp/Global.asax.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions SampleApp/Web.config
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="QuartzNetWebConsole" verb="*" path="quartz/*" type="QuartzNetWebConsole.ControllerFactory, QuartzNetWebConsole"/>
</handlers>
</system.webServer>
<runtime>
Expand Down

0 comments on commit 0c251a5

Please sign in to comment.