I've just inherited a website (ASP.Net 2.0) written by someone else that I need to maintain.
The code is not horrible, but it has a number of things that make the website run incredibly slow.
I have an idea to monitor this, and I want to see what more experienced developers think of it.
My objective right now is to find out when pages ...
I need a method to run every so often that does some database processing. However, I may need it to be triggerable by an admin on the site. But I don't want this method being run more than once at the same time, as this could cause issues with the way it hits the database.
For example, could I...
Create a singleton class that runs th...
Hello,
A couple of questions regarding the role of global.asax:
Why is it not included in the Website Project in Visual Studio? Are there other ways of achieving the same functionality without this file?
If I would create a Web Application project, as far as I remember, a global.asax file would be created. If I were to delete it, would...
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 proje...
I am wondering under what circumstances I should be putting application initialisation code in Application_Start() vs Init() in my Global.asax file?
The distinction between the two doesn't seem very obvious to me, other than Application_start gets called first, then Init().
Why would I use one over the other?
Does it really make a di...
Hi
I have always had issues with identifying the errors in applications from the error reports I get. Currently I build an email with information about the error containing.
User
Url
Error Message
Time And Date
This is the code I use
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Dim _UserIpAddress as stri...
I am trying to perform some actions at the end of every request.
I changed the Application_Start() that is generated when created new project to make a test:
protected void Application_Start()
{
EndRequest += (s, e) =>
{
Console.Write("fghfgh");
};
RegisterRoutes(RouteTable.Routes);
}...
Hi folks,
i want to check if the Session contains some key/value data, in my global.asax. I'm not sure when the earliest possible time (and method name) is, to check this.
thanks :)
...
Consider a web application that resizes large tiff files on the fly. Each large tiff file is resized into a jpg thumbnail and larger jpg when the user invokes the operation. The dimensions of these converted files is always the same.
During a code review yesterday, one of the other developers asked me why I set those dimensions in my gl...
One of our applications has a mechanism for emailing our Helpdesk automatically should it encounter a certain level of exception. One particular exception, a NullReferenceException, is causing a few problem and I believe it is caused by IIS recycling and losing the session.
To prove this I want to log when the application is started/sto...
Here's what I'm trying to do in my Global.asax.vb:
Public Class MvcApplication
Inherits System.Web.HttpApplication
Shared Sub RegisterRoutes(ByVal routes As RouteCollection)
routes.IgnoreRoute("{resource}.axd/{*pathInfo}")
routes.MapRoute( _
"Error", _
"error.html", _
New With...
Hi!
I need to replace some data that's sent from every page on my site, and I think doing it with Global.asax. This is what I have tried with so far:
void Application_PreSendRequestContent(object sender, EventArgs e)
{
System.IO.StreamReader sr = new System.IO.StreamReader(Response.OutputStream);
String output = sr.ReadToEnd();...
I'm creating an ASP.NET MVC application. I need to handle exceptions in two places.
Global.asax.vb file:
Public Class MvcApplication
Inherits System.Web.HttpApplication
...
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
LogException(HttpContext.Current.Server.GetLastError(), Request)
End Su...
Hi,
My goal is to write a cookie when the user authenticates. We are using a crappy framework that hides its source code and event model so when I use their login control I can't set a session timeout on it!
Anyhow, I am trying to write a cookie when the user is logged in, and then refresh the cookie expire time on subsequent page vie...
I am using Global.asax to perform logging at the end of each request via the Application_EndRequest event. However, I am seeing some odd behavior of certain values stored in the HTTPContext.Current.Items collection.
Below is the debug output for a nullable Enum. You can see that there is a value, but HasValue resolved to False?!
{Syst...
I have this simple Application_Error method in my global.asax, and it does not redirect in case an exception occurs under medium trust. Can someone tell me whats wrong here.
This code works fine under full trust
void Application_Error(object sender, EventArgs e)
{
Response.Redirect("~/error.aspx",false);
}
...
After deployment on IIS 6 methods declared in Global.asax (for Application Start, etc.) are not executed. The same code on IIS 5 works properly. What can be the reason? Is it the problem with permissions/configuration?
...
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...
I have two questions:
1) I have a few global variables for my website declared in my global.asax file. They are simple, small key/value pairs and there are only a few of them. Is this a good practice for values that are small and need to be accessed by almost every page on my website? Storing them in the database and requiring a db look...
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."
...