global-asax

global.asax and classic ASP?

Now please excuse me if this is a stupid question - BUT... In my ASP.NET apps, I have a global.asax file that catches an error and emails me the details. 'Could' I put the global.asax in the root of a classic ASP file and if there was an ASP error it would trigger the global.asax? Again sorry if this is a dumb question.. If not any ...

Handle application_start without global.asax

Is there a way to handle the application_start "event" without using the global.asax? The best I can come up with is an HttpModule that checks some static variable on every begin_request, which is INCREDIBLY wasteful :( Do I have any other options? Thanks ...

classic asp/asp.net website - global.asa not working

Hi, I've recently been given a website written in classic asp to configure and set up - although it also appears to have pages written in asp.net. The problem I'm having at the moment is that it doesn;t appear to be picking up settings from the global.asa file such as Application("ConnectionString").... As when I try to write them out...

ASP.NET Accessing cookie value in session_end event of global.asax

In ASP.NET , How can i retrieve a cookie value in the Session_End event of global.asax file ? The following code is throwing an exception "Object reference not set to an instance of an object" string cookyval = ""; try { cookyval = Context.Request.Cookies["parentPageName"].Value; } catch (Exception ex) ...

Can I show an alert from Global.asax on a page that's experiencing a SQL Timeout?

In Global.asax, is there a way to handle SQL Timeouts elegantly, and display a message on the requesting page explaining the error? I know Global.asax has the Application_Error and Error events, but I'm not sure which (if any) I could use to accomplish this. Related, can I access the page instance which raised the error that Global.asa...

.net Session state has created a session id, but cannot save it because the response was already flushed by the application.

Hi, i have below in my global.asax Session_Start string myBrowser = Utils.SafeUserAgent(Request); foreach (string bannedbrowser in BrowserBan.BrowsersToBan) { if (myBrowser.IndexOf(bannedbrowser, StringComparison.OrdinalIgnoreCase) > -1) { HttpContext.Current.Response.Redir...

What can cause Application_Error not to be invoked?

Hi guys, For the last 2 weeks I have a case that I can't figure it out, maybe you guys already passed through the same problem or ear/read about it and can help me. I have an ASP.NET Project that I run on my machine and other machines fine, every time I try to temper the QueryString I get an error that is been thrown by the System.Exce...

ASP.NET Application Start without using Global.asax

Hello, I'm developing a plugin like application for a web site. Due to requirements it will live in the same physical path and the same application pool as the main web site which I do not have the source code for. So they both share the same Web.config and some other dependencies. I need to set a license for a third party dependency a...

Using the Ninject NLogModule Logger in global.asax

I'm using Ninject for DI in my asp.net application, so my Global class inherits from NinjectHttpApplication. In my CreateKernel(), I'm creating my custom modules and DI is working fine for me. However, I notice that there is a Logger property in the NinjectHttpApplication class, so I'm trying to use this in Application_Error whenever a...

Subscribing Events in Global.Asax

I have some couple of events like when user subscribes to my newsletter it fires a subscribed event so that an e-mail will be sent to corresponding users to notify them about their subscriptions. But where should I handle those events ? What is the best practice to handle events ? Should I bind event handlers to events in Subscribe Butto...

Do data source binding in Global.asax??

Hi~guys... I knew global.asax normally is used for session stuffs, or error handling. However, I saw someone's code, and he did data source binding in global.asax. Moreover, it's like every source he might used in there...Whould this cause any serious problem? or it's just ok...? and, any advantage of it? By the way...Sorry i forgot whe...

Help debugging - when does the Application_Start run in global.asax file?

Here's the snippet from my Global.asax: <script runat="server"> void Application_Start(object sender, EventArgs e) { // log this call EventLogger.Log("ApplicationStart"); } void Application_BeginRequest(object sender, EventArgs e) { // log what the user is doing UsageLogger.Log(UsageLogger....

urlauthorization with custom roleprovider

I am interacting with a third party httpmodule for authentication. I implemented my custom roleprovider to interact with that. However they use a CustomPrincipal instead of the expected RolePrincipal for urlauthorization. In which event in global.asax can I hook to grab the customprincipal, instantiate a new RolePrincipal and copy over ...

Call javascript function from global.asax in asp.net mvc

How to call or make the javascript function from the Application_Start of global.asax in asp.net mvc(C#) application? ...

How to do something firstly when the asp.net server start

Hi all I need an interface that can be run firstly when the application start. We can write some code in Application_Start of global.ascx. Is there any other method to finish it after some configurations in web.config,i don't wanna write any code in global.ascx You know,we can implement the Interface 'IHttpModule' to diy each request. Bu...

ASP.NET MVC app custom error pages not displaying in shared hosting environment

I'm having an issue with custom errors on an ASP.NET MVC app I've deployed on Go Daddy. I've created an ErrorController and added the following code to Global.asax to catch unhandled exceptions, log them, and then transfer control to the ErrorController to display custom errors. This code is taken from here: protected void Applicati...

Generating the standard ASP.NET 'uncaught exception' page HTML from the exception itself?

Hi all. Is it possible to generate the HTML page normally shown for an uncaught exception in ASP.NET, using an Exception object? I have an app that catches an exception in Global.asax -> Application_Error, and does a Server.Transfer() to our pretty general-error page. I have an #if DEBUG flag that's pulling out the Exception from Serve...

Application_Error event in Global.asax not firing in Release Mode? ASP.NET MVC application

I'm working on an ASP.NET MVC application. I'm having a problem where my Application_Error() event in my Global.asax file isn't firing in Release Mode. If I compile in Debug it fires just fine. PS: I'm using NLogger to log my runtime errors. Any help is appreciated. Thanks. ...

Application_Start() event in global.asax

Hai guys, My website has thousands of users... I have implemented a background task of sending mails to every user once a day ... I followed this link to do this... http://www.codeproject.com/KB/aspnet/ASPNETService.aspx My question is will Application_Start() will be fired for every user hitting my website... If so every user...

Log4Net logging IP address of a single session accross several threads

Please refer to: http://stackoverflow.com/questions/1340643/how-to-enable-ip-address-logging-with-log4net which explains how to log an IP using log4net. My problem is that in certain cases extra threads are spawned that belong to a session. Now I need log4net to understand (or the thread) to be able to log with the correct IP. Current...