You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.
Hi,
We are using owin with asp.net mvc/webapi in most of our projects. The application makes Mvc settings and other registrations in owin startup, and Glimpse's HttpModule starts before owinstartup. So our registrations like our custom viewengine, our custom controllerfactory overrides Glimpse's registrations. So I need to initialize glimpse httpmodule after owinstartup.
If I call Init method after owinstartup, it throws exception because of HttpApplication events can't be register after init method.
For workaround, I did this with reflection and custom events:
private HttpModule glimpseHttpModule;
private void InitializeGlimpse()
{
glimpseHttpModule = new HttpModule();
var glimpseHttpModuleType = typeof(HttpModule);
var glimpseRuntimeMethod = glimpseHttpModuleType.GetMethod("GetRuntime", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
var glimpseRuntime = (IGlimpseRuntime)glimpseRuntimeMethod.Invoke(glimpseHttpModule, new[] { new HttpApplicationWrapper(WebApplication.Instance).Application });
if (glimpseRuntime.IsInitialized || glimpseRuntime.Initialize())
{
var beginRequestMethod = glimpseHttpModuleType.GetMethod("BeginRequest", BindingFlags.Instance | BindingFlags.NonPublic);
var beginSessionAccessMethod = glimpseHttpModuleType.GetMethod("BeginSessionAccess", BindingFlags.Instance | BindingFlags.NonPublic);
var endSessionAccessMethod = glimpseHttpModuleType.GetMethod("EndSessionAccess", BindingFlags.Instance | BindingFlags.NonPublic);
var endRequestMethod = glimpseHttpModuleType.GetMethod("EndRequest", BindingFlags.Instance | BindingFlags.NonPublic);
OnBeginRequest += (context, e) => beginRequestMethod.Invoke(glimpseHttpModule, new[] { new HttpContextWrapper(((HttpApplication)context).Context) });
OnPostAcquireRequestState += (context, e) => beginSessionAccessMethod.Invoke(glimpseHttpModule, new[] { new HttpContextWrapper(((HttpApplication)context).Context) });
OnPostRequestHandlerExecute += (context, e) => endSessionAccessMethod.Invoke(glimpseHttpModule, new[] { new HttpContextWrapper(((HttpApplication)context).Context) });
OnPostReleaseRequestState += (context, e) => endRequestMethod.Invoke(glimpseHttpModule, new[] { new HttpContextWrapper(((HttpApplication)context).Context) });
}
}
I've removed module settings in web.config, and I'm calling this method end of the Configure method of owin startup. It's working, but I rather not to use reflection and custom event handlers. I'm triggering theese event handlers in HttpApplication like this:
I know that Glimpse doesn't support owin middlewares yet. But I don't need middleware support right now neither. What I need is starting Glimpse module when I want.
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Hi,
We are using owin with asp.net mvc/webapi in most of our projects. The application makes Mvc settings and other registrations in owin startup, and Glimpse's HttpModule starts before owinstartup. So our registrations like our custom viewengine, our custom controllerfactory overrides Glimpse's registrations. So I need to initialize glimpse httpmodule after owinstartup.
If I call Init method after owinstartup, it throws exception because of HttpApplication events can't be register after init method.
For workaround, I did this with reflection and custom events:
I've removed module settings in web.config, and I'm calling this method end of the Configure method of owin startup. It's working, but I rather not to use reflection and custom event handlers. I'm triggering theese event handlers in HttpApplication like this:
I know that Glimpse doesn't support owin middlewares yet. But I don't need middleware support right now neither. What I need is starting Glimpse module when I want.
The text was updated successfully, but these errors were encountered: