global-asax

ASP.NET :Access Session variable in global.asax

人走茶凉 提交于 2019-12-01 16:18:49
I have an ASP.NET application and in the Global.asax ' Application Error Event, I am calling a method to trace/log the error.I want to use the session variable content here .I used the below code void Application_Error(object sender, EventArgs e) { //get reference to the source of the exception chain Exception ex = Server.GetLastError().GetBaseException(); //log the details of the exception and page state to the //Windows 2000 Event Log GUI.MailClass objMail = new GUI.MailClass(); string strError = "MESSAGE: " + ex.Message + "<br><br><br>" + "SOURCE: " + ex.Source + "<br>FORM: " + Request.Form

How can I programmatically stop the current website? [duplicate]

一笑奈何 提交于 2019-12-01 08:03:23
问题 This question already has answers here : How can I programmatically stop or start a website in IIS (6.0 and 7.0) using MsBuild? (3 answers) Closed 4 years ago . I am using the MVC5 for an web application. The web app runs in IIS7 or greater. In the Global.asax on application_start , the number of licenses will be set: protected void Application_Start() { try { MyApp.cNumberOfLicenses = COM.GetNumberOfLicenses(); } catch(Exception e) { // log exception // stop web site. } } If any expection

Application_Start is not firing in IIS

北城余情 提交于 2019-12-01 06:47:23
In my web application, I had given some set of coding's in the APPLICATION_START() in Global.asax file. Its been working while I run it on the development server. Whereas, when I hosted it in IIS, the Application_Start event is not firing . Can any one help me to get rid of this... Thanks in advance. No idea if this is your situation, but in case it helps, this happened to me with the following conditions: I am using Microsoft.Web.Infrastructure.DynamicModuleHelper The IIS application pool is set to use Integrated Pipeline mode (it works ok with Classic) I do not have a

Where is the “magic” happening when a Controller instantiates the correct implementation of the Interface in Web API DI?

喜你入骨 提交于 2019-12-01 05:51:58
问题 It seems to me that somewhere a rabbit is being pulled out of a hat when it comes to DI in Web API Controllers. I grok that: 0) The Controller in a Web API project can be called with various classes to be instantiated, all of which implement the interface on which the Controller depends. e.g., with this Controller code: private readonly IDepartmentRepository _deptsRepository; public DepartmentsController(IDepartmentRepository deptsRepository) { if (deptsRepository == null) { throw new

ASP.NET Session_End event not firing

余生长醉 提交于 2019-12-01 05:42:32
I'm trying to get a database transaction to execute when an ASP.NET session ends (in simple WebForms app on Windows 2008 Server). I realize that many respondents will suggest not to rely on the Session_End event (as I've read in a hundred forum posts on this topic yielded by a Google search). Please humor me. I've done these things: Enabled session state in web.config: <sessionState mode="InProc" cookieless="false" timeout="1" /> Confirmed that the Session_End event does NOT fire when I call Session.Abandon() OR when the session times out. Confirmed that the session IS timing out after 1

When's the earliest i can access some Session data in global.asax?

杀马特。学长 韩版系。学妹 提交于 2019-12-01 02:29:47
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 :) I always believed Application_AcquireRequestState was the first event in Global.asax that could access the current session. It's definitely not Application_BeginRequest . MSDN casually mentions that the session state is acquired during Application_PostAcquireRequestState event. I wish it was restated at the Life Cycle Overview page. The latest you can access session state is in Application_PostRequestHandlerExecute, as it is

mvc route actionlink url use name instead of id

馋奶兔 提交于 2019-11-30 21:10:21
I think I already asked this but the solution didn't really made sense. Anyway, I have ActionLinks on my views like this: foreach( var item in Model){ <%: Html.ActionLink(item.Name, "Details", new {id = item.Id}) %> } now, when it goes to my Action Details obviously this will be the url /MyThings/Details/{id} I was wondering if it's possible to show the name of that item instead of the id Using a slug? or modifying the global asax like so: /MyThings/Details/CarKeys The thing is the names need to be unique, is there a way I can modify the global asax to show the name instead of the id? Any

Global.asax event that has access to session state

萝らか妹 提交于 2019-11-30 19:04:25
I'm trying to access the session state in my global.asax for every request (page, documents, PDF, etc.). I know i can't do that in Application_BeginRequest, and i thought i could in Application_AcquireRequestState, but it won't works, which is strange because it works in another project. So, i'm looking for an event in which i would always have access to the session state for every request. Thanks EDIT: @Mike I tried doing this Sub Application_PreRequestHandlerExecute(ByVal sender As Object, ByVal e As EventArgs) Session("test") = "test" End Sub But i still get errors as i don't have access to

global.asax breakpoint not hit

纵饮孤独 提交于 2019-11-30 17:47:50
I have some code in my ASP.NET app in C# that's in the Global.asax.cs code file. In the Application_Start , Session_Start and Application_Begin Request I have set some breakpoints. However none of these are ever hit. I'm working on my local machine with VS8. Here's what I've tried: Stopped the ASP Dev Server Deleted all ASP.NET Temporary files Created new Global.asax Closing VS and opening back up Clean and Rebuild project Upon trying my after these, the breakpoints will not hit. Any ideas why this might be? Jeff Reddy I've run into this same problem. I'm assuming you are using your local IIS

Can Session_End fire on window close? (ASP.NET)

久未见 提交于 2019-11-30 17:34:12
问题 I am putting an "online" counter on a website, and I have run into these two contradicting sources. This one (I am using this example code): http://aspdotnetfaq.com/Faq/How-to-show-number-of-online-users-visitors-for-ASP-NET-website.aspx ...says that: Also when user closes his browser or does not click on any links in our website, session expires, and our "OnlineUsers" global variable is decreased. However, this one: http://www.velocityreviews.com/forums/t383710-session-end-guarantee.html ..