diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2013-03-26 11:19:06 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2013-03-26 11:19:06 -0700 |
commit | 3d37ff45cab6838d80b22e6b782a0b9b4c2f4aeb (patch) | |
tree | c15816c3d7f6e74334553f2ff98605ce1c22c538 /samples/OAuthServiceProvider/Code/Global.cs | |
parent | 5e9014f36b2d53b8e419918675df636540ea24e2 (diff) | |
parent | e6f7409f4caceb7bc2a5b4ddbcb1a4097af340f2 (diff) | |
download | DotNetOpenAuth-3d37ff45cab6838d80b22e6b782a0b9b4c2f4aeb.zip DotNetOpenAuth-3d37ff45cab6838d80b22e6b782a0b9b4c2f4aeb.tar.gz DotNetOpenAuth-3d37ff45cab6838d80b22e6b782a0b9b4c2f4aeb.tar.bz2 |
Move to HttpClient throughout library.
Diffstat (limited to 'samples/OAuthServiceProvider/Code/Global.cs')
-rw-r--r-- | samples/OAuthServiceProvider/Code/Global.cs | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/samples/OAuthServiceProvider/Code/Global.cs b/samples/OAuthServiceProvider/Code/Global.cs index 60fed9f..37206ab 100644 --- a/samples/OAuthServiceProvider/Code/Global.cs +++ b/samples/OAuthServiceProvider/Code/Global.cs @@ -10,6 +10,10 @@ /// The web application global events and properties. /// </summary> public class Global : HttpApplication { + private readonly object syncObject = new object(); + + private volatile bool initialized; + /// <summary> /// An application memory cache of recent log messages. /// </summary> @@ -95,17 +99,6 @@ private void Application_Start(object sender, EventArgs e) { log4net.Config.XmlConfigurator.Configure(); Logger.Info("Sample starting..."); - string appPath = HttpContext.Current.Request.ApplicationPath; - if (!appPath.EndsWith("/")) { - appPath += "/"; - } - - // This will break in IIS Integrated Pipeline mode, since applications - // start before the first incoming request context is available. - // TODO: fix this. - Constants.WebRootUrl = new Uri(HttpContext.Current.Request.Url, appPath); - Global.TokenManager = new DatabaseTokenManager(); - Global.NonceStore = new DatabaseNonceStore(); } private void Application_End(object sender, EventArgs e) { @@ -128,8 +121,30 @@ } } + private void Application_BeginRequest(object sender, EventArgs e) { + this.EnsureInitialized(); + } + private void Application_EndRequest(object sender, EventArgs e) { CommitAndCloseDatabaseIfNecessary(); } + + private void EnsureInitialized() { + if (!this.initialized) { + lock (this.syncObject) { + if (!this.initialized) { + string appPath = HttpContext.Current.Request.ApplicationPath; + if (!appPath.EndsWith("/")) { + appPath += "/"; + } + + Constants.WebRootUrl = new Uri(HttpContext.Current.Request.Url, appPath); + Global.TokenManager = new DatabaseTokenManager(); + Global.NonceStore = new DatabaseNonceStore(); + this.initialized = true; + } + } + } + } } }
\ No newline at end of file |