You could also create a new Global.cs and let Umbraco inherit from that. Here is an example:
Global.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace Umbraco.Extensions.Utilities
{
public class Global : Umbraco.Web.UmbracoApplication
{
public override string GetVaryByCustomString(HttpContext context, string custom)
{
if (custom.ToLower() == "url")
{
return "url=" + context.Request.Url.AbsoluteUri;
}
return base.GetVaryByCustomString(context, custom);
}
}
}
If you want to replace those values (which you don't have too if you only want to use events) I think it's best to override the Global.asax like I did in my example.
That's cool, except I only found EndRequest and Error, and this is my class now
public class Global : Umbraco.Web.UmbracoApplication { public void Init(HttpApplication application) { application.EndRequest += (new EventHandler(this.Application_EndRequest)); application.Error += new EventHandler(Application_Error); }
Listening, as I've run into the exact same problem now.
The document that Jeroen points to has examples on all v4.x of Umbraco, plus v6.1. Which is strange, since 6.1 looks like a future version. And it doesn't seem like it is a typo (fx. should have read 6.0.1) as, just as Hardi states, I can't find anything equivalent to Application_Start.
I was using the URL rewriting in UMBRACO 4.7.2 on my custom Global.asax file into the Application_BeginRequest method. Now I'm trying to upgrade to version 6.0.0 where I saw that I have to change my custom Global.asax to inherit from Umbraco.Web.UmbracoApplication.
No problems so far in general in the application, but when the global.asax triggers the HttpContext.Current.RewritePath(URL), after migrating to version 6, the method does not rewrite the URL at all. It does not give any error or exception, it simply doesn't rewrite the URL, and consequently the system returns 404 , file not found.
Any ideas about it? Did the version 6 of Umbraco stop to support the HttpContext.Current.RewritePath method in its new Global.asax?
Global.asax replacement in Umbraco 6
I had the following in my Global.asax (Umbraco 4.7)
Now I have upgraded to Umbraco 6.0.3, which global.asax inherits from
Umbraco.Web.UmbracoApplication
Where do I put my event handlers (and what are the equivalent method names for each)?
Thanks in advance!
You can find more info here: http://our.umbraco.org/Documentation/Reference/Events/application-startup
You could also create a new Global.cs and let Umbraco inherit from that. Here is an example:
Global.cs:
Global.asax from Umbraco
Hi Jeroen, thank you for your quick reply.
I have looked into IApplicationEventHandler (since I'm using Umbraco 6.0.3) and extending Umbraco.Web.UmbracoApplication.
However my problem remains: Which one do I use and what methods can I use to replace:
I couldn't find all 5 of them on either of those class, and implementing IApplicationEventHandler gives me this error:
Values cannot be returned until Resolution is frozen
If you want to replace those values (which you don't have too if you only want to use events) I think it's best to override the Global.asax like I did in my example.
Jeroen
That's cool, except I only found EndRequest and Error, and this is my class now
Do you know what are the equivalent for:
Listening, as I've run into the exact same problem now.
The document that Jeroen points to has examples on all v4.x of Umbraco, plus v6.1. Which is strange, since 6.1 looks like a future version. And it doesn't seem like it is a typo (fx. should have read 6.0.1) as, just as Hardi states, I can't find anything equivalent to Application_Start.
/Soeren
I'm also still waiting for an answer.
You can override OnApplicationStarted but I couldn't use it (Request is unavailable yet at that point)
The closest I could find so far is this
Looks like I've got the following working with v6.0.5:
Somebody knows how to use Application_Error in the IApplicationEventHandler? Or how do i catch a http 400 error?
Hi all,
I was using the URL rewriting in UMBRACO 4.7.2 on my custom Global.asax file into the Application_BeginRequest method. Now I'm trying to upgrade to version 6.0.0 where I saw that I have to change my custom Global.asax to inherit from Umbraco.Web.UmbracoApplication.
No problems so far in general in the application, but when the global.asax triggers the HttpContext.Current.RewritePath(URL), after migrating to version 6, the method does not rewrite the URL at all. It does not give any error or exception, it simply doesn't rewrite the URL, and consequently the system returns 404 , file not found.
Any ideas about it? Did the version 6 of Umbraco stop to support the HttpContext.Current.RewritePath method in its new Global.asax?
Thanks in advance to all of you!
Hi All,
I have the same problem with version 6.2.6.
Did anyone find the way how to solve it?
Thanks Ihor
is working on a reply...