global-asax

How to get username in global asax?

Hi there, I am trying to check if the user belongs to someone's friendlist from the database and redirect him accordingly. I am doing this in a routehandler called by Global Asax. I just want to know how to get the username (from the login information) in the route handler class (or Global asax) I used this: string username = HttpC...

HttpApplicationState not available in an MVC controller

Hi, I'm using MVC2 and VS2010 developing a website and need to use Application State global values. I can set a value like 'Application["hits"]=0;' in Global.asax but when trying to use the same in an MVC controller always get the following error: The name 'Application' does not exist in the current context I have also tried using in...

Application_error function intermittently catch "File does not exist"

Hi, I am using Appilcation_Error event for handling the exceptions and it catches almost all exceptions correctly. However in some pages it catches with some exception "File does not exist" and I am not able to find from where it exactly occurs. When I comment the Application_Error code, surprisingly that web page works fine. My main c...

static ChannelFactory in Global.asax.cs throws CommunicationObjectFaultedException

Hello, I am using the following code in my Global.asax.cs file: public static readonly IMyCommunicationService GlobalCommunicationChannel = new ChannelFactory<IMyCommunicationService>("NetTcpBinding_IMyCommunicationService").CreateChannel(); From every website I am accessing the static var "GlobalCommunicationChannel". That ...

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...

ASP.NET - Sending 500 Error Information To Yourself

Where would I need to hook in (at what event) to be able send myself every 500 error that happens on my current ASP.NET project. Something inside the global.asax? And I'd like to send myself the output that the user would see. The white/yellow/black 500 standard ASP.NET error HTML. My users only see the errors about 10% of the time. The...

Deploy mvc.net on none root IIS app folder

Hi, The title may be a little unclear, but I didn't know how to describe it otherwise. The problem is the following: I have an mvc website and 2 servers, a testing server and the real server. the problem is: the testing server folder is a root folder, so the adress is: http://www.testingserver.com/ -> this poses no problem. but now ...

Raise Session_OnStart event from custom ASP.NET SessionStateProvider class

I'm working on an asp.net project that uses an in-house developed custom SessionStateProvider class. Evidently, the Session_OnStart event is not firing. I have code in Global.asax to handle the event. I can only get this code to execute by changing the Web.config to use the default SessionStateProvider. What must I do to make my Sess...

will application_end be called when all users session end?

hi all i have a smqll question, will the application_end event in global.asax gets called when all users end there session? was it like this in the past maybe? ...

ASP.NET - Global asax resetting once in a while

Hi guys, I've got an website running on a third-party hosting server. Now I've got a few objects in global asax. But once in like 6 hours or so (didn't really check how long) the object gets reset to default values. Is this an problem in global asax that it reset's himself or is this the server on which I'm hosting? ...

global.asax works on local computer but not after i publish to server

i think this has been asked before but i just cannot figure this one out. I have added a global.asax file to my project (using asp.net with c# from vs2010) and works great on my local machine. then when i publish to our site (i publish to ftp site and then copy from the ftp folder into the site folder overwriting old files) and it doesn'...

Is there any way to get acces and change to Page before leave the server?

Hi, I want to change page content while it is going from the server because i need to add some advertisements inside the html elements that are advertisement holder. protected void Application_PreSendRequestContent(object sender, EventArgs e) this is good but i couldn't get access to HttpContext . Should i, i don't know :) But in thi...

global.asax Application_Error not firing

My global.asax seems not to be firing. I have: void Application_Error(object sender, EventArgs e) { // Code that runs when an unhandled error occurs Server.Transfer("~/ExceptionFormView.aspx"); } In my web.config, I don't have anything lie CustomErrors. As I want everything to be handled by Global.asax and transferred to Exc...

Session variable getting lost?

Given this Global.asax.cs: using System; using System.Web; namespace Foo.Web { public class Global : HttpApplication { private const string IntroductionPageShownSessionKey = "IntroductionPageShownSessionKey"; protected void Application_AcquireRequestState(object sender, EventArgs e) { ShowIntroductionIf...

Global.asax file not giving Exception Message

Hi Here's my problem I have some code and I'm using it to send an e-mail with the last error details but all I want is the (Inner)Exception Message to be displayed in the email with the URL Here's my code Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) ' Get current exception Dim err As System.Exception =...

Windows Authentication to Custom Authentication working with Profile

I Use windows authentication with profile and wanted to flip to a custom authentication. My question is How can I specify that my user is authenticated and how to set the Profile.UserName. I Know the Profile.UserName is ReadOnly . In my Web.Config, i change the authentication mode="None" and configure IIS to enabled Anonymous. In the...

Multiple Global.asax files per web application project

I have existing web application project in which i need to add new subdirectory. In this subdirectory i need to add WCF service. Question is: Can i use different AppDomain then services from root directory? Also, can i add new global.asax just for this subdirectory? ...