Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi, I've implemented global.asax file, and I have two issues:
1) from some reason, Global.asax.cs fils is never being hit. 2) I used a work-around to solve it (not that I like that). It looks like this:
<%@ Application CodeBehind="Global.asax.cs" Inherits="Umbraco.Web.UmbracoApplication" Language="C#" %> <script RunAt="server"> protected void Session_Start(object sender, EventArgs e) { // Session start logic here } protected void Application_BeginRequest(object sender, EventArgs e) { var x = 1; } protected void Application_EndRequest(object sender, EventArgs e) { } protected void Session_End(object sender, EventArgs e) { } protected new void Application_Error(object sender, EventArgs e) { Exception ex = HttpContext.Current.Server.GetLastError(); Umbraco.Core.Logging.LogHelper.Error(this.GetType(), ex.Message, ex); }</script>
it works, BUT, the Application_Error event is being called twice!
Please help, Rotem
Rotem, in my Global.asax I'm instead overriding the OnApplicationError method, and seems to be working fine:
protected override void OnApplicationError(object sender, EventArgs e) { base.OnApplicationError(sender, e); if (Context.IsCustomErrorEnabled) GlobalErrorHandler.TransferToCustomErrorPage(this, e, ContentNavigator.CustomErrorPageUrl); if (!Request.IsLocal || Context.IsCustomErrorEnabled) { GlobalErrorHandler.SubmitException(Server.GetLastError()); } }
The content inside the method is just our implementation of course.
-Tor
HI Tor, Thank you for the reply. I'll try that. do you happen to know why my .cs file code is not being fired. and I have to write my code in
<script runat="Server">
?
thanks
You know, I haven't actually tried that, but I think you'd have to place the codebehind file in the App_code folder. Maybe try this: CodeBehind=”~/App_Code/global.asax.cs” (and also place the file there of course).
CodeBehind=”~/App_Code/global.asax.cs”
Hi Tor, Unfortunately it doesn't work. :(
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Global.asax - error fires twice
Hi, I've implemented global.asax file, and I have two issues:
1) from some reason, Global.asax.cs fils is never being hit. 2) I used a work-around to solve it (not that I like that). It looks like this:
it works, BUT, the Application_Error event is being called twice!
Please help, Rotem
Rotem, in my Global.asax I'm instead overriding the OnApplicationError method, and seems to be working fine:
The content inside the method is just our implementation of course.
-Tor
HI Tor, Thank you for the reply. I'll try that. do you happen to know why my .cs file code is not being fired. and I have to write my code in
?
thanks
You know, I haven't actually tried that, but I think you'd have to place the codebehind file in the App_code folder. Maybe try this:
CodeBehind=”~/App_Code/global.asax.cs”
(and also place the file there of course).-Tor
Hi Tor, Unfortunately it doesn't work. :(
is working on a reply...