global.asax

Global.asax and Logging

Is there an event that I can tap into in Global.asax to execute some SQL in ADO.NET for logging every time a request is made to the application? ...

maintain pageViews in global.asax (asp.net)

I need a function in global.asax file which gets called only once when user enter a page url. application_beginrequest gets called 50-60 times in a single page( as to render a page several requests go to server.) i though of a solution - I can write my fucntion in global.asax and call it on page load of other pages but in that solution...

Setting a session variable in Global.asax causes AJAX errors

I'm getting a very peculiar problem with my asp.net application, it took me an age to track down but I still don't know what is causing this behaviour. If I set a session variable in the Application_PreRequestHandlerExecute event, then my external JavaScript files are ignored, and therfore causing a raft of errors. I have simplified the...

global.asax and ASP.NET MVC solution Organization

I am refering to this article from Jimmy Bogard He is suggesting two projects to organize your ASP.NET MVC solution. Basically, one project for the code and another for the rendering My concern is about global.asax file. Jimmy suggested separating global.asax from global.asax.cs and put them in two differents projects When I did thi...

Session_Start, IIS7 and constant session resets

I have been using Session_Start to make database transactions as a way of tracking server activity. We recently migrated to a new server with IIS7 and suddenly some of our most active sites seem to be abandoning/restarting sessions constantly with the same session ID each time. This is of course wildly inflating our access counts and b...

Saving a list of items in Application State ASP.NET MVC ?

Hi Guys, I'm having a bit of trouble with knowing how I can save items from a list I have in Application state in the global.asax as- Application[""]. My controller basically takes in some user input, I then pass this to another classes Method as parameters it gets added to a list all the time. This data thats getting added to the list...

Global.asax, definition of routes

Hello!, I have a question about global.asax that I don't really understand. My scenario is that I have this route defined : routes.MapRoute( "Suspensions", "Suspension/{action}/{id}/{prev}", new { controller = "Suspension", action = "Index", id = "", prev = "" } ); T...

Why is there a markup file associated with the Global.asax.cs?

The purpose of the code associated with the Global.asax is to hold functionality to respond to various application-level events. But why is there a markup file associated with the Global.asax.cs? I presume this is an ASP.NET implementation side effect? ...

Get Control who send to postback on Global.asax

Hi, i can know in Global.asax which control do the current postback???? ...

Global.asax not firing for .aspx pages in IIS7

We run a link redirection service which can handle links thrown at it in various formats. One of these formats is to append the destination URL to the end of the link, for example http://url.fwd/abcd/http://www.mydomain.com/page.aspx This was working on a Windows Server 2003 / IIS6 box for the last two years, but now we're trying to mo...

ASP.NET Application_Error don't redirect

Hello, In ASP.NET, I need redirect to a custom page when file size is exceeded. The application executes the code inside file test.aspx in Me.Server.Trasnsfer in other errors but when is an too big file error the web browser don't render it and shows that cannot show the page. Sub Application_Error(ByVal sender As Object, ByVal e A...

Redirect in Application_Error redundant if using customErrors?

If I have a customErrors section in my Web.config that says to redirect to Error.html, then putting code in the Application_Error method in the Global.asax to redirect to Error.html is redundant is it not? Technically, I could bypass the Web.config by redirecting to a different page in the Application_Error method if I wanted to, but si...

two global.asax files

I have an application inside a website hosted on IIS 6.0 can I have two global.asax- one for root website and another for inside application. if I can have how to make them running as I was not able to make inner global.asax files run ...

redirection from ASP.NET MVC Global.asax

Hi, I am making a project in ASP.NET MVC. Now what i want is, if someone goes to something.mydomain.com. Then the user should be redirected to a specific controller. Can i achieve this through Global.asax. Please help me out. ...

Rate Limiting with ASP.NET and the global.asax

What is a good simple way to only allow one request per IP per second using ASP.NET's global.asax file? Is there something else built-in to ASP.NET that I'm not thinking of? If possible I'd like to only ignore requests that are multiple POSTs from jQuery's Ajax functions. I'm trying to fix a pervasive problem in an existing legacy app. ...

Will one global WCF ChannelFactory in global.asax limit my asp.net project?

Hello, I create one global ChannelFactory connection to my WebService (in global.asax) and I access this CannelFactory from every web-request. My WCF-Service uses: InstanceContextMode = InstanceContextMode.Single ConcurrencyMode = ConcurrencyMode.Multiple .Net 4.0 netTcpBinding no security, no metadata exchange Now my questions: ...

Calling the Session before any Controller Action is run in MVC

Hi, I have this authentication check in my global.asax file in the Session_OnStart() call: if (Session["Authenticated"] == null) { Response.Redirect("~/Login.aspx"); } This kind of session authentication is tightly coupled in all our web apps so I have to use it this way. This global.asax sits in an older ...

ASP.NET customErrors with mode=remoteOnly and global.asax handling exceptions

I have custom errors set in the web config file as follows: <customErrors mode="RemoteOnly" defaultRedirect="GenericError.aspx" /> Fine and dandy... I like that mode="RemoteOnly" facilitates development... For unhandled exceptions, I have in global.asax: Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) Respons...

Using regular expressions in .NET MVC route to handle upper-case characters

I am working on a .NET MVC application and am trying to write a route in global.asax.cs. The goal is, I want any URL that contains an uppercase character to run through said route. The idea is, the router will lowercase the URL and redirect it. My approach is to use a regular expression to handle this. Here's what I have: routes.Map...

Why would I need WCF for building RESTful services?

I've recently discovered a way to implement RESTful services using Global.asax (by handling the Application_BeginRequest event). Basically, I am saying it is possible (and easy) to implement a RESTful web service in classic ASP.NET, without any need for WCF. It takes approximately 30 lines of code to figure out which method you want to ...