I need a bit of code in my Application_BeginRequest, but i can see that it is not possible to create a new global.asax because of the App_global.asax.dll - from what I can find of information it should instead be possible to create a class in App_Code, inheriting from umbraco.Global and then override the Application_BeginRequest byt nothing happens. What am I missing;
public class MyGlobal : umbraco.Global { protected override void Application_BeginRequest(object sender, EventArgs e) { base.Application_BeginRequest(sender, e);
Your blog post is actually one of the articles I have spent most time studying (maybe you can recognize the name of the class), but as far as I can see I do exactly what is written in "UPDATE – July 11, 2010 19:59" except that I use BeginRequest instead of Start.
Except for creating the file in the App_Code and inserting the code from my question, or the code from your blog post, will I need to do something else?
The guide requires deleting of the App_global.asax.dll which I have read in other post would be a bad idea, especially in newer versions of Umbraco. Deleting the file would make it much easier as it is then possible to insert my own global.asax - but I see this as the last way out.
I also tried writing HttpHandler-option but without success - maybe I should try a bit more untill we hopefully find the right solution with inheriting umbraco.Global :)
In 4.1 onwards you can inherit from global.asax and override the methods so no need to remove global.asax.dll I see you are using 4.5.1 hence you should be able to override.
Really, whole point of putting it in was for situations where you need to tap into global events like wiring up IOC etc we made specific request via codeplex after client requested it. Cant see why it wont work?
You'd still need a way to tell Umbraco to use your class though wouldn't you? Which is usualy done by modifying the global.asax file to tell it which calss to inherit from.
Application_BeginRequest
I need a bit of code in my Application_BeginRequest, but i can see that it is not possible to create a new global.asax because of the App_global.asax.dll - from what I can find of information it should instead be possible to create a class in App_Code, inheriting from umbraco.Global and then override the Application_BeginRequest byt nothing happens. What am I missing;
public class MyGlobal : umbraco.Global
{
protected override void Application_BeginRequest(object sender, EventArgs e)
{
base.Application_BeginRequest(sender, e);
//code
}
}
When debugging I never enters the above code.
Umbraco 4.5.1 - ASP.NET 3.5
Hi Kim,
Have a read of my blog post on a similar subject, the first one probably isn't any use, but the second 2 show you how you can extend the global.asax
http://blog.mattbrailsford.com/2010/07/11/registering-an-application-start-event-handler-in-umbraco/
Another option might be to use a HttpHandler instead, and just register it in your web.config as those trigger on every request anyway.
Many thanks
Matt
Hi Matt
Your blog post is actually one of the articles I have spent most time studying (maybe you can recognize the name of the class), but as far as I can see I do exactly what is written in "UPDATE – July 11, 2010 19:59" except that I use BeginRequest instead of Start.
Except for creating the file in the App_Code and inserting the code from my question, or the code from your blog post, will I need to do something else?
Hmm, maybe I've missed a few steps.
I'd have a look at Ismails blog, where he sets up log4net via a custom HttpApplication, his seems to be a lot more complete.
http://ismailmayat.wordpress.com/2009/05/19/integrating-log4net-into-umbraco-site/
I'll have a look at updating my post with more details.
Many thanks
Matt
The guide requires deleting of the App_global.asax.dll which I have read in other post would be a bad idea, especially in newer versions of Umbraco. Deleting the file would make it much easier as it is then possible to insert my own global.asax - but I see this as the last way out.
I also tried writing HttpHandler-option but without success - maybe I should try a bit more untill we hopefully find the right solution with inheriting umbraco.Global :)
Hi Kim,
Yea, if it's on every request, I reckon a HTTPHandler is probably your safest bet.
Let me know if you have any issues
Many thanks
Matt
Kim,
In 4.1 onwards you can inherit from global.asax and override the methods so no need to remove global.asax.dll I see you are using 4.5.1 hence you should be able to override.
Regards
Ismail
Kim,
If you reflector into umbraco dll and take a look at class global you have
So create your new class inherit from global and over ride that should then allow your stuff to be hit.
Regards
Ismail
That won't work Ismail.
Just create an HttpModule (derive from IHttpModule) and add it to the web.config, much safer and re-usable!
(search for IHttpModule to find out more)
Really, whole point of putting it in was for situations where you need to tap into global events like wiring up IOC etc we made specific request via codeplex after client requested it. Cant see why it wont work?
Regards
Ismail
You'd still need a way to tell Umbraco to use your class though wouldn't you? Which is usualy done by modifying the global.asax file to tell it which calss to inherit from.
Matt
Matt,
RATS!!!!
Regards
Ismail
is working on a reply...