.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Using Global.asax to Set Session Variables Pulled From SQLServer

Posted By:      Posted Date: September 03, 2010    Points: 0   Category :ASP.Net
I have a custom class that pulls user information from a SQL Server table. Now that I'm expanding the site from a single page to others. I want to shift the code to the Session_Start event so that the information is always loaded when the site is accessed. How do I call my custom code from global.asax since its script and not a class. 

View Complete Post

More Related Resource Links

Session end and global.asax



I'm wondering if ther's a simple way of achieving the following.

When a new session starts, I create some cookies and session objects from global.asax session start.

If a user logs out, I want to abandon the session - I presume using session.abandon, and i also want to clear the cookies.  They are set to expire after the session ends (no expiry date).  This may be an automatic thing, but I've not tested as yet.

When a user logs back in again I want to recreate those objects - in other words, kick off global.asax again.  Is that what happens or do I need to recreate manually?



Session and global asax


i use session state for logged in  users
if session lost(finished) for user and i use this session to insert as a forien key in a table
this will generate runtime error as this id become equal to zero
how can i develop a method to log out the user automatically when session timeout reached
inseted to check at every button on the velue of session.
i have ideia to check on session on global file in Application_BeginRequest event

but give me error
what do you think of this method???

Session Events of Global.asax doesn't fire in sharepoint

As I have some requiremnt, i've written some code in session_start and session_end events in global.asax of the sharepoint web applicaion. But the events don't fire when the user logs in or logs out. Even the application_start also not working when the application starts. So do i need to make any changes in web.config or anywhere ? Please help.

Session_End in Global ASAX: Is the Session still there until Session_End completes?


I'm trying to do some "housecleaning" with my application.  When the Session_End event fires, I'm wondering, is the Session still there?  Does the Session disappear AFTER the Session_End event completes, or is it gone beforehand?  In other words, can my Session_End event call subroutines that rely on the Session variables?  I'm wanting to log the fact that a particular session ended.  Can I do this in global.asax? 

SessionStart/Session End in global.asax in Sharepoint



Can I modify the global.asax in sharepoint.

I want to implement httpModule and global.asax for session start and session end events.

Kindly help.

redirect from Application_AuthenticateRequest in global.asax in session time out



i want to redirect the user from ?????the ??AuthenticateRequest in the global.asax file when session timeout ?happens.

is it possible.





Session and Application Variables


I have a web application in which i need to logout the user if he clicks the logout button or even if he closes his browser window. On Logout button click, i am doing session.Abandon(), but how to go about his browser window close.

Can anybody help with a code sample.

Quick Error messages with Global.asax

The article Quick Error messages with Global.asax was added by lykasd on Wednesday, August 11, 2010.

Error pages without any effort void Application_Error(object sender, EventArgs e) { Server.Transfer("/error.aspx"); //Displays the error page } In error.aspx add this to the content area. p>We're sorry, but the %=Server.GetLastError

Windows 7, IIS 7.5 and VS2010: can't edit global.asax


Hey and thanks!


As the subject line notes the software in use, anyone have an idea why I can't edit global.asax in VS2010 (being ran with the 'run as administrator' advanced property check box checked)?  The file properties in explorer show local machine admins have full control (I am in that category) and also that IIS has windows auth enabled for the default web site.  What is this other level of security on here that I'm missing?  I can edit web.config, vb files and general aspx files with no problem--just the global.asax file causing a headache...





ASP.NET MVC 2 - I have a serious concern about the management of session variables.


I have a serious concern about the management of session variables.
I state that I have Windows Web Server 2008.
Currently values in the controller and call a session variable like this:
I have an action in as:
System.Web.HttpContext.Current.Session ['name'] = id_userlogged;

Defining session variables...



This is a pretty basic question.

I have some code where I need to define a session variable  however it's coming back as Nothing when the code is executed. Here's the code:

' Default Currency

REQCURR = Request.Querystring("p_DCURR")
'If not explicitly specified, try to get it from session

If (REQCURR = "") Then

     If (Session("REQCURR") <> "") Then
          REQCURR = Session("REQCURR")

          'Here is the session variable I'm trying to define:
          Session("REQCAD") = 0
          REQCURR = ""
     End If

End If


So, for some reason that Session("REQCAD") = 0 has no value instead of having a value of 0.

Any thoughts?


Global Variables and data types

Hi, I have a small issue with the datatype problems. This is what my scenario is. I have a global variable "Qtr" declared as "Int32" datatype. Next, i have a ActiveXscript with VBScript Language. With the below piece of code. All it does, it will calculate and assign the calculated value to the global variable "Qtr". But due to some datatype conversion problem it is not displaying the Calculated value. It is showing null. But the value in the local variable is getting displayed. Can anyone figure out what the problem is all about. I have the option of taking the String datatype for the global variable but in the next step in the workflow , we have an stored procedure call i.e. an execute sql task where we will be call a stored procedure EXEC sp ? where the parameter datatype is an INT in the database. That is why i am finding problem.  I have used the work around i.e. using SSIS advanced expressions and avoided the parameter mapping and all. Function Main() 'msgbox("test") Dim Qtr Dim currentYear 'Constants qYears = 3 Qtr= (currentYear - qYears) * 10 + 4 msgbox(Qtr) msgbox("Assigning the value to the variable") DTSGlobalVariables("Qstart").Value =  Cint(Qtr) msgbox("Display Value in the variable") MsgBox(DTSGlobalVariables("Qtr").Value)      End Function Can a

I have a problem Global.asax

Master  Desing        <head runat="server"><title><asp:ContentPlaceHolder ID="TitleContent" runat="server" />    </title>    <link href="../../Content/Site.css" rel="stylesheet" type="text/css" />    <link href="../../Content/menu/chromestyle2.css" rel="stylesheet" type="text/css" />    <script src="../../Scripts/menu/chrome.js" type="text/javascript"></script></head>   Global.asax  //Routes Event Catagory  routes.MapRoute("eventCatagory", "Catagory/{catagoriesID}/{catagories}",                                 new { controller = "Catagory", action = "Catagory", catagories = "", catagoriesID = UrlParameter.Optional }); //Routes Event Catagory Detailroutes.MapRoute("eventCatagoryDetail", "Catagory/{subCatagoryID}/{subCatagoryname}",                        &n

Need to access session variables in an ashx?

Dear All,In my project i need to set session in an ashx file and access that session in aspx.cs file. for this i am dooing the following things.In .ashx filepublic class Upload : IHttpHandler , System.Web.SessionState.IRequiresSessionState{    public void ProcessRequest(HttpContext context)    {            HttpPostedFile postedFile = context.Request.Files["Filedata"];            context.Session["img"] = postedFile.FileName;    }}After the file upload happand i wrote the code in .aspx.cs fileprotected void Button1_Click(object sender, EventArgs e)    {        Response.Write(Session["img"].ToString());    }this is working fine in IE but in Mozilla,Chrome,safari and Opera i got Session["img"] is null. Any help can be appreciatedThanks & Regards Basheer K M Cybrosys Technologies Pvt. Ltd. Calicut. http://www.cybrosys.com

Global variables between different JS files

I have two different Javascript files, A.js and B.js. I would like to make a variable available in A.js to B.js. A.js is invoked first and the coding in it just listens for events. B.js is always running and doing something. How do I share a variable defined in an A.js function for B.js to use? I have tried finding the answer in google but its taking forever to find a pertinent scenario.

Function in Global.asax is not running

Hi, I am using a Global.asax in on my webpage to run a function with an interval. In this test I have set the interval to 1 minute to be able to see what happens. I have declared a timer in the Application Start which should mean that when I open up the webpage after I have uploaded the Global.asax the timer will start.   However with this code below where I try to create a file named newFile.txt, this file is not created. I cant really understand what I could be missing. It seems that the function is not running ?<%@ Application Language="C#" %> <%@ Import Namespace="System" %> <%@ Import Namespace="System.Collections.Generic" %> <%@ Import Namespace="System.Linq" %> <%@ Import Namespace="System.Web" %> <%@ Import Namespace="System.Web.UI" %> <%@ Import Namespace="System.Web.UI.WebControls" %> <%@ Import Namespace="System.Drawing" %> <%@ Import Namespace="System.Net.Mail" %> <%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.Threading" %> <%@ Import Namespace="System.IO" %> <%@ Import Namespace="System.Text" %> <%@ Import Namespace="Microsoft.Win32" %> <%@ Import Namespace="System.Reflection" %> <%@ Impo

Global.asax Application_BeginRequest

When I was in the link page is a link to the site all the program, Application_BeginRequest event in Global.asax is triggered, But my link is a link to an external time will not trigger this event, and I ask when my link is connected to an external URL, How to trigger Application_BeginRequest event Thank you.   Such as web link in the URL if connected to yahoo, I take it lead to another page.  Protected Sub Application_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs) Dim originalPath As String = HttpContext.Current.Request.Url.Host.ToLower() If originalPath.Contains("yahoo") Then Context.Response.Redirect("StopUrl.aspx") End If End Sub  
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend