httpapplication

HTTPModule Event Execution Order?

Does anyone know of a site or page, or know the order of execution for the events of the HTTPApplication class for HTTPModule event execution? I found the MSDN Documentation for all of the events, but it doesn't show a list of process steps and I haven't been able to find one. ...

Where do I catch and handle maxAllowedContentLength exceeded in IIS7?

Hi all, I have an aspx page where I’m allowing a user to upload a file and I want to cap the max file upload size to be 10MB. IIS7, .NET 3.5. I have the following configured in my web.config file: <location path="foo.aspx"> <system.web> <!-- maxRequestLength: kbytes, executionTimeout:seconds --> <httpRuntime maxRe...

asp.net MVC, how to work with HTTPApplication class

How do I go about gathering site statistics in MVC? (users online.. etc?) ...

Getting ApplicationState in asp.net without HttpContext

I got a webapp that stores a config object in ApplicationState. This object contains the connection string to the database among other things. Sometimes i start a async thread to do a few longer running tasks, like sending emails and updating the database. However since this thread don't have a HttpContext i can't get at the config obj...

Why don't PreSendRequestHeaders and PreSendRequestContent run consistently?

When working with HTTP modules, has anyone noticed that the final two events in the pipeline -- PreSendRequestHeaders and PreSendRequestContent -- don't always run? I've verified that code bound to EndRequest will run, but will not when bound to either PreSendRequestHeaders or PreSendRequestContent. Is there a reason why? I thought pe...

AuthenticateRequest event

Hello, Q1 - To my understanding FormsAuthenticationModule is subscribed to AuthenticateReuqest event, and thus only after this event is fired, is FormsAuthenticationModule called. But the following quotes got me a bit confused: A) The AuthenticateRequest event signals that the configured authentication mechanism has authenticat...

global asax application_start application begin_request methods ???

I have a problem. While migrating from classic pipeline mode to integrated pipeline mode at IIS 7.0 we encounter the problem : Server Error in '/' Application. Request is not available in this context... We found solution for this problem at mvolo.com/blogs/serverside/archive/2007/11/10/Integrated-mode-Request-is-not-available-in-this...

Why is HttpApplication constructor called several times

Hi, Can somebody explain why the constructor of a custom class derived from HttpApplication is called several times upon application startup? My code structure is the following: - My Global class in global.asax derives from CustomApp class. - The CustomApp class derives from HttpApplication class The Global class is created at start...

ASP.Net Session State

Hi, I was wondering whether it would be possible to change the sqlConnectionString used for SessionState in ASP.net based upon the domain an application is running on? A scenario; We have 20 sites running from one application all talking to different databases depending which domain (site) they are browsing from. When browsing www.d...

How to test HttpApplication Object with HttpApplicationState

I am trying to test a 'plugin' for an ASPNET HttpApplication that is loaded on Application_Start. The code is something like this: private HttpApplication application; public void Application_Start(object sender, EventArgs e) { this.application = sender as HttpApplication; StartReportService(); } p...

Unit testing an HttpApplication

I have a class derived from HttpApplication that adds some extra features. I'm to the point where I need to unit test these features, which means I have to be able to create a new instance of the HttpApplication, fake a request, and retrieve the response object. How exactly do I go about unit testing an HttpApplication object? I'm using...

Global.asax issue

Hello everyone, I am developing an HttpModule and using Global.asax. I have developed a class which derives from HttpApplication, but Application_Start method of my class never executes (I create a file at the beginning of Application_Start but the file never creates, and it is why I think Application_Start never executes). I am using V...

C# ASP.NET HttpModules: HttpApplication Events

Hi All, I have an HttpApplication (Global.asax) in my web application, I use this to catch and log unhandled Exceptions and to setup WebFormURLRouting. This all works, however I want to move this code into my Application Framework, (ie not in Global.asax.cs) I have just tried to create an HttpApplication class in the framework but it s...

Application_BeginRequest for static *.JS files in ASP.NET in IIS6?

I'm trying to do something seemingly simple: ensure that Application_BeginRequest is called for every static *.JS URL sent to my IIS6 website, whether or not the underlying file exists. What's a good way to do this on IIS6 & ASP.NET 3.5, ideally without causing all static files to go through ASP.NET-- only the .JS URLs? If you're cur...

How to show a custom 404 page in ASP.NET-MVC?

When any URL is 404 on my site, i want to show a custom 404 page that is rendered with ASP.NET-MVC. Hoewever i do not want to use the wildcard route approach because that would disable standard webforms. My code currently looks like this: if (serverException is HttpException && ((HttpException)serverException).GetHttpCode() == 404) { /...

How to create a barebones HttpApplication for ASP.Net (without Webforms or MVC)

Ok I am wanting to learn more about how ASP.Net works under the hood. I mean beneath MVC or Webforms and other such frameworks. Basically I want to know how those frameworks are wired onto ASP.Net so that they work with IIS. What would be the bare minimum for creating a simple HttpApplication which worked with IIS and used neither MVC o...

Application_Start versus OnInit versus constructor

I've gone rounds with this ever since I started programming classic ASP 12 (or so) years ago and I've never found a great solution because the architecture of ASP and ASP.NET has always been a swamp of bad practices, magic shared singletons, etc. My biggest issue is with the HttpApplication object with its non-event events (Application_S...

Quote from MSDN about System.Web.HttpApplication

Quote from http://msdn.microsoft.com/en-us/library/4wt3wttw.aspx: One instance of the HttpApplication class is used to process many requests in its lifetime. However, it can process only one request at a time. Thus, member variables can be used to store per-request data. Why per-request? Maybe per set of requests? Seems t...

Best HttpApplication event for altering the response source

I intend to build a HttpModule in order to scan a response's source and make small adjustments, mainly altering urls (hrefs, actions, srcs, etc). I see the HttpApplication has a plethora of events that can be handled and I'm not sure of the best stage at which it's safe to alter the HTML content that goes back to the browser. I need to...

ASP.NET Intermittent lag before Application_BeginRequest()

I'm using ASP.NET MVC 2. When in Debug mode, there is a very consistent 5-10 second delay on every other request to the server before HttpApplication_BeginRequest() is hit in Global.asax It happens exactly every other request. In Release mode it is fast always but it's causing me problems testing things in Debug mode. I looked at the ca...