global-asax

Application_Start not being hit in ASP.NET web app

时光怂恿深爱的人放手 提交于 2019-11-30 13:01:19
I'm trying to debug something in the global.asax.cs file in an ASP.NET web app and have set a breakpoint in the Application_Start() event however that event is not getting fired when I start the web app inside VS2008. I'm targeting the 3.5 framework. What could prevent this event from being fired? Or how could I have messed up the project such that this event is no longer wired up? If i remember correctly, Application_Start runs before the debugger can hook up to the application. Try doing something else to check if the Application_Start method runs, like setting an application variable:

Unhandled Exceptions with Global.asax

為{幸葍}努か 提交于 2019-11-30 09:10:04
I am emailing unhandled exception details from global.asax. How can I get the path and/or filename of the aspx file or assembly file where an exception was not handled. This info was showing up in the exception's stack trace when I was developing & testing. When I deployed the global.asax to production, this info is no longer showing up in the stack trace. Is there a way to get to this info while I build my MailMessage object in Global.asax? Thanks If this is a ASP.NET application, which the tag suggest it is, you should be able to do something like this... The ctx.Request.Url.ToString() would

Global.asax in Umbraco 6

烂漫一生 提交于 2019-11-30 09:08:17
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)? Aximili 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.PreRequestHandlerExecute += new EventHandler(application_PreRequestHandlerExecute); application

Global 301 redirection from domain to www.domain

无人久伴 提交于 2019-11-30 07:14:59
问题 could i use the begin request of Global.asax to redirect everything, from mydomain.domain to www.mydomain.domain ? If this one is true, how can i do that? 回答1: protected void Application_PreRequestHandlerExecute(Object sender, EventArgs e) { string currentUrl = HttpContext.Current.Request.Path.ToLower(); if(currentUrl.StartsWith("http://mydomain")) { Response.Status = "301 Moved Permanently"; Response.AddHeader("Location", currentUrl.Replace("http://mydomain", "http://www.mydomain"));

BeginRequest-like filter in MVC 3?

☆樱花仙子☆ 提交于 2019-11-30 04:58:38
I have some code in my application that I need to execute on every request, before anything else executes (even before authentication). So far I've been using the Application_BeginRequest event in my Global.asax, and this has worked fine. But this code needs to hit the database, and doing this from Global.asax doesn't feel right for some reason. Also, the Ninject.MVC3 nuget I'm using won't inject dependencies into my HttpApplication ctor. So what I decided to do is move this code into its own global action filter. The problem I'm having now is that no matter what Order or FilterScope I give

Global.asax event that has access to session state

耗尽温柔 提交于 2019-11-30 02:59:10
问题 I'm trying to access the session state in my global.asax for every request (page, documents, PDF, etc.). I know i can't do that in Application_BeginRequest, and i thought i could in Application_AcquireRequestState, but it won't works, which is strange because it works in another project. So, i'm looking for an event in which i would always have access to the session state for every request. Thanks EDIT: @Mike I tried doing this Sub Application_PreRequestHandlerExecute(ByVal sender As Object,

How can I use Server.MapPath() from global.asax?

二次信任 提交于 2019-11-29 18:54:11
I need to use Server.MapPath() to combine some files path that I store in the web.config . However, since Server.MapPath() relies on the current HttpContext (I think), I am unable to do this. When trying to use the method, even though its "available", I get the following exception: Server operation is not available in this context. Is there another method that can map a web root relative directory such as ~/App_Data/ to the full physical path such as C:\inetpub\wwwroot\project\App_data\ ? You could try System.Web.Hosting.HostingEnvironment.MapPath() . No HttpContext required. Kiran Banda Use

Application_Start not being hit in ASP.NET web app

让人想犯罪 __ 提交于 2019-11-29 18:29:49
问题 I'm trying to debug something in the global.asax.cs file in an ASP.NET web app and have set a breakpoint in the Application_Start() event however that event is not getting fired when I start the web app inside VS2008. I'm targeting the 3.5 framework. What could prevent this event from being fired? Or how could I have messed up the project such that this event is no longer wired up? 回答1: If i remember correctly, Application_Start runs before the debugger can hook up to the application. Try

Get same instance of a component registered with Autofac as InstancePerLifetimeScope in Global.asax methods as is injected into a controllers?

爱⌒轻易说出口 提交于 2019-11-29 16:02:55
I have a situation where I need to manually instantiate some objects in Application_BeginRequest that are dependent on some of the same components that I've registered with Autofac. I'd like to use the same instances of components that I've registered with Autofac with InstancePerLifetimeScope for injection into my MVC and WebAPI controllers. My config for both MVC and Web API works as expected, and an example of a component registration looks like so: builder.Register(c => new MyDbContext()).AsSelf().InstancePerLifetimeScope(); Now I want to use that same instance in the class I'm

Unhandled Exceptions with Global.asax

怎甘沉沦 提交于 2019-11-29 12:37:34
问题 I am emailing unhandled exception details from global.asax. How can I get the path and/or filename of the aspx file or assembly file where an exception was not handled. This info was showing up in the exception's stack trace when I was developing & testing. When I deployed the global.asax to production, this info is no longer showing up in the stack trace. Is there a way to get to this info while I build my MailMessage object in Global.asax? Thanks 回答1: If this is a ASP.NET application, which