global-asax

Global.asax in Umbraco 6

匆匆过客 提交于 2019-12-03 19:30:53
问题 I had the following in my Global.asax (Umbraco 4.7) Application_Start Application_EndRequest Application_Error Session_Start Session_End 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)? 回答1: This is what I found so far. You can create your own class public class Global : Umbraco.Web.UmbracoApplication { public void Init(HttpApplication application) { application

Handling exceptions in global.asax ASP.NET MVC

老子叫甜甜 提交于 2019-12-03 12:57:06
I have code which is catching all exceptions in Global.asax protected void Application_Error(object sender, EventArgs e) { System.Web.HttpContext context = HttpContext.Current; System.Exception exc = context.Server.GetLastError(); var ip = context.Request.ServerVariables["REMOTE_ADDR"]; var url = context.Request.Url.ToString(); var msg = exc.Message.ToString(); var stack = exc.StackTrace.ToString(); } How I can get controller name where this error happened How I can get request client IP? And can I filter exceptions? I dont need 404, 504.... erors thanks Global.asax has not notion of

Global.asax parse error after minor change and revert to previous version

萝らか妹 提交于 2019-12-03 11:10:01
The project in context is: ASP .NET Web Application .NET Framework: 4 Platform Target: x86 IDE: Visual Studio 2010 Ultimate SP1 Multiple projects in solution with ASP .NET being the startup project. It has been in production for months without glitches until yesterday. I cleaned up the [Global.asax] file (removed unused using statements, refactored, etc.), ran the solution and got the following error: Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file

how do you wire up Application_BeginRequest() in asp.net-mvc

江枫思渺然 提交于 2019-12-03 09:19:35
i see in global.aspx.cs from an asp.net-mvc project protected void Application_BeginRequest() { } but when i try to add this to my project, i don't see what is calling this method. I see that the base System.Web.HttpApplication has this event but i don't see anything overriding it or subscribing to this event. Can someone explain how you wire up Application_BeginRequest in asp.net-mvc? I'm afraid Cos's answer isn't quite accurate. You don't have to wire it up because the base HttpApplication class does it for you. There isn't an interface or an override here; HttpApplication uses reflection to

Customised error messages are not translated in ASP.NET MVC 4

为君一笑 提交于 2019-12-03 08:55:13
I want to translate the validation message "The field Date must be a date." I've added the following keys into Application_Start() at Global.asax ClientDataTypeModelValidatorProvider.ResourceClassKey = "ModelBinders"; DefaultModelBinder.ResourceClassKey = "ModelBinders"; I've created ModelBinders.resx, ModelBinders.nl.resx, ModelBinders.fr.resx in App_GlobalResources. I've added the following string resources (or translations) in the .resx files: Name Value ==== ===== FieldMustBeDate The field {0} must be a date. FieldMustBeNumeric The field {0} must be a number. PropertyValueInvalid The value

Understanding routing in Global.asax (asp.net-mvc)

丶灬走出姿态 提交于 2019-12-03 07:14:59
In Global.asax what does the following signify? routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); This is one of the really frustrating things about learning MVC - the documentation for this feature is awful - there's just hardly anything there: http://msdn.microsoft.com/en-us/library/dd470170(VS.100).aspx . routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); This allows all the something.axd files to run outside of MVC - that "{*pathInfo}" at the end allows query strings to be ignored (it's kind of a wildcard). Note that this doesn't apply any such wildcard to the path, so: trace.axd?clear=1 /

Global.asax - Application_Error - How can I get Page data?

泄露秘密 提交于 2019-12-03 01:33:27
I have this code: using System.Configuration; void Application_Error(object sender, EventArgs e) { Exception ex = Server.GetLastError().GetBaseException(); string ErrorMessage = ex.Message; string StackTrace = ex.StackTrace; string ExceptionType = ex.GetType().FullName; string UserId = Getloggedinuser(); string WebErrorSendEmail = ConfigurationManager.AppSettings["WebErrorSendEmail"]; // save the exception in DB LogStuffInDbAndSendEmailFromDb(); } This is (most of) my code. In a small percentage of cases, I don't get enough information though. I don't know what page the exception originated

how many times is System.Web.HttpApplication is initialised per process

痞子三分冷 提交于 2019-12-02 23:10:28
I have the global.asax which extends from a custom class I created, called MvcApplication which extends from System.Web.HttpApplication . In it's constructor, it logs application start as per below: protected MvcApplicationGeneral() { _log.Info("logApplicationStartToTextFile"); } When I went to look in the log file, this seems to be called A LOT of times, not just once per application start. I placed another log entry in Application_Start and that seems to be called only once. Is the Global.asax class instantiated per request, or much more frequently than just once per application? Multiple

Application Restart for folder deleted,added,updated

微笑、不失礼 提交于 2019-12-02 09:44:56
Modifying, adding, or deleting certain types of files within the application's known folders will cause the application to restart.But when Log file in application is updated,why application is not restart. Then PropertyInfo p = typeof(System.Web.HttpRuntime).GetProperty("FileChangesMonitor", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); object o = p.GetValue(null, null); FieldInfo f = o.GetType().GetField("_dirMonSubdirs", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.IgnoreCase); object monitor = f.GetValue(o); MethodInfo m = monitor.GetType().GetMethod

Events in Global.asax are not firing

余生颓废 提交于 2019-12-01 17:48:29
问题 In my ASP.Net application, I can't get the events in Global.asax to fire on my machine. For instance, Session_Start will not fire. The same Global.asax works fine on other development machines in my office. I have tried: Both the ASP.Net Development Server and my local IIS Rebooting the machine Removing and recreating the file from the project (including deleting it from disk) All machines are configured the with the same level of software (VS2008 SP1, .Net 3.5, XP) This is driving me crazy,