global-asax

.NET Application_BeginRequest - How to get User reference?

瘦欲@ 提交于 2019-11-26 17:11:01
问题 I'm trying to get a reference to the user object in my Global.asax file's Application_BeginRequest . I'm using the property Context.User but I get a NullReferenceException . Is it possible to get a user object reference in Application_BeginRequest? 回答1: You don't have access to the User object because the request hasn't yet been authenticated. Try using Application_AuthenticateRequest instead. Here is an explanation of all Global.asax events: https://web.archive.org/web/1/http://articles

How to handle session end in global.asax?

家住魔仙堡 提交于 2019-11-26 15:28:39
I'm working in chat application, I used HashTable for containing User and Operator as a Key & Object of ChatRoom Class as a value of HashTable. Main problem is that When user or Operator close browser or disconnected without logout then It is automatically logout on the end of the session. Please help me related to that and how to use Global.asax in this matter. You can use global.asax's session end event to remove the unexpectedly disconnected user : void Session_End(Object sender, EventArgs E) { // Clean up session resources } but beware, session doesn't end when the user closes his browser

“Could not load type [Namespace].Global” causing me grief

痞子三分冷 提交于 2019-11-26 15:14:11
In my .Net 2.0 Asp.net WebForms app, I have my Global.asax containing the following code: <%@ Application CodeBehind="Global.asax.cs" Inherits="MyNamespace.Global" Language="C#" %> However when I build I get an error stating- Could not load type 'MyNamespace.Global'. This seems to be because the MyNamespace namespace (defined in the code behind file Global.asax.cs) is not seen by the compiler in the Global.asax file (does not show in R# intellisence..). This turned out to be a very hard nut to crack... any help will be appreciated! Note: The Global.asax and the Global.asax.cs are located in

ASP.NET MVC Url Route supporting (dot)

百般思念 提交于 2019-11-26 08:56:05
问题 I hope that you can help me with the below problem. I am using ASP.NET MVC 3 on IIS7 and would like my application to support username\'s with dots. Example: http://localhost/john.lee This is how my Global.asax looks like: (http://localhost/{username}) routes.MapRoute( \"UserList\", \"{username}\", new { controller = \"Home\", action = \"ListAll\" } ); The applications works when I access other pages such as http://localhost/john.lee/details etc. But the main user page doesn\'t work, I would

“Could not load type [Namespace].Global” causing me grief

故事扮演 提交于 2019-11-26 04:19:36
问题 In my .Net 2.0 Asp.net WebForms app, I have my Global.asax containing the following code: <%@ Application CodeBehind=\"Global.asax.cs\" Inherits=\"MyNamespace.Global\" Language=\"C#\" %> However when I build I get an error stating- Could not load type \'MyNamespace.Global\'. This seems to be because the MyNamespace namespace (defined in the code behind file Global.asax.cs) is not seen by the compiler in the Global.asax file (does not show in R# intellisence..). This turned out to be a very