global-asax

How to create Global variables, ASP.NET, global asax

I have some data layer classes that r to be used very frequently, Almost in whole site. I was working on window application previously and i used to create its object in module (vb.net) but now i m working in C# and on ASP.NET. Now i need to do same thing so that i need not create same object multiple times on every page. I want to use ...

ASP.global_asax is missing from compiled Assembly

I am using aspnet___compiler.exe to compile my asp.net 3.5SP1 websites, then aspnet_merge.exe to merge the assemblies into a single one. The assembly is then uploaded to the production server. This usually works pretty well but sometimes when testing on the staging server I get the following message: Parser Error Message: Could not ...

Mapping Interfaces to Methods in Global.asax

I was recently at a Techdays seminar, at the SOLIDify Your Microsoft ASP.MVC MVC Applications session. The instructor had a demo that had mapping Interfaces to Methods from the Global.asax file OnApplication_Start(). So anywhere in the web application he could simply do IDate.GetMyDate() and it would return the date. I was wondering...

Programmatically disable FileAuthorizationModule on selected requests

I would like to be able to selectively disable the FileAuthorizationModule early in the request pipeline for certain requests (which will be handled later on by my own code in any case). The UrlAuthorizationModule seems to respect the Context.SkipAuthorization = true boolean, is there an equivalent to disable the FileAuthorizationModule...

Castle Windsor PerWebRequest LifeStyle and Application_EndRequest

Hi Gang, I'm registering some components related to Linq2Sql using PerWebRequest lifestyle. I see them get created, but they get destroyed before my global's Application_EndRequest method gets called. Is that by design? Does anyone know a work around? I want to call commit on my UnitOfWork object to submitchanges() at the end of e...

it is possible to Debug Global.asax?

I cant debug global.asax file! i have some codes in Application_Start() method but when I set break point in method it is ingonred! is this normal? ...

Trying to convert Global.asax 1.0 file to 3.5 Issues with Application_Error + Session and Redirect...

So in the Global.asax is this: protected void Application_Error(object sender, System.EventArgs { Session["CustomError"] = Server.GetLastError(); Server.ClearError(); Response.Redirect("~/ErrorPage.aspx"); } And in ErrorPage.aspx is this: private void Page_Load(object sender, System.EventArgs e) { Excep...

ASP .NET 301 redirect create problem for some users

This is the code I use to redirect from www. to non www. version of my site void Application_BeginRequest(object sender, EventArgs e) { string authority = Request.Url.Authority; if (authority.StartsWith("www.")) { authority = authority.Remove(0, 4); string newUrl = "http://" + authority + Request.Url.PathAndQ...

ASP.NET Threading Issue

Problem: I am working on a ASP.NET 2.0/C# Application and I need to do the following: I have a function I am using from a third-party library lets say MyFunctions.CalculateTotal(int a, int b); A known issue is that the thread locks resources. So there is another function that needs to be called afterwards to clean everything up. M...

Difference between Application_Start and Application_OnStart

I'm in the process of adding ASP.NET MVC code to a preexisting ASP.NET Webforms project. The various tutorials suggest adding routing to a method called from Application_Start() in Global.asax. My Global.asax already has an Application_OnStart(Object,EventArgs) method with some setup code. If I try to have both Start and OnStart, the On...

Global 301 redirection from domain to www.domain

Hello, 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? ...

ASP.NET : Get URL of error page in global.asax's Application_OnError

I have an ASP.NET application where i am tracking my applicaion level erros using golabl.asax On_Error method.I will send an email to my id when there is some error happened in the site(ie :" when the application _error being invoked) Now From my global.asax's Application_OnError event, how can i get the URL of the page where this error ...

ASP.NET:,Will session variables exist when Application_Error method being called from global.asax ?

In ASP.NET ,Will session variables exist when Application_Error method being called from global.asax ?Can i access values of my session variables there ? ...

Which redirection is better - web.config or global.asax

I need to redirect some of the older pages in my application to new pages. I thought urlMapping in web.config is the efficient way to achieve this. But there is also another way to redirect using global.asax. Which one is the efficient way for this. At what point in request execution does this asax and config file comes into the picture?...

ASP.NET - Log User Session Start/End Times for Audit Trail - Global.ASAX?

My ASP.NET intranet web application uses Windows Authentication, and I would like to record the following details: 1) Windows ID 2) Session Start Time 3) Session Stop Time 4) URL being browsed to (optional) I've got some basic code setup in "Session_Start" method of the Global.ASAX to log session start times (seen below), but that's it...

ASP.NET - Get SessionID while in from the Global.ASAX

I'm recording the session start times from when people log into my .NET 2.0 web application, but I'd also like to record the Session ID. Can someone give me some example code on how to accomplish this (how to access the Session ID from within the Global.ASAX). If you need any additional info just let me know. ...

ASP.NET MVC routing conflict - null value for input variable

I'm at a loss as to why my routes are conflicting. I have these in my Global.asax file: routes.MapRoute( "CustomerView", "{controller}/{action}/{username}", new { controller = "Home", action = "Index", username = "" } ); routes.MapRoute( "Default", "{controller}/{action}/{id}", ne...

ASP.NET: Large number of Session_Start with same session id

I'm running a ASP.NET website on my development box (.NET 2.0 on Vista/IIS7). The Session_Start method in global.asax.cs logs every call to a file (log4net). The Session_End method also logs every call. I'm using InProc session state, and set the session timeout to 5 mins (to avoid waiting for 20 mins). I hit the website, wait for 5 mi...

How to keep images (and other files) out of ASP.NET Pipeline

How can I prevent certain file types from going through the ASP.NET Pipeline (hitting global.asax, etc.)? ...

How to write a global redirect in C#?

A client has sent out an email with a link containging a typo for a website we run [E.g. http://example.com/?id=123.]. What is the best way to re-direct anyone who visits the bad URL? If someone clicks on the link, can we catch it in the Global.asax, checking if the path ends with "." then removing it and re-directing? If so, where in G...