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


Post New Web Links

Session cast - loss of session? and other weird thing :D

Posted By:      Posted Date: September 17, 2010    Points: 0   Category :ASP.Net
 
Hey all..I have a 2 questions (yes they should be in 2 seperate posts)1.) (more of a statement) when I was on my windows XP pro with asp.net 4.0 installed - I was able to use "response"  in the global.asax ......now that I have windows 7 with asp.net 4.0 I come up with an exception (which is odd) and yes i know it should come up with an exception  it just doesnt make sense why it works on my old 32bit system2.) when I call a static method in a class to  create a dataset in the "session_start" section of the "global.asax" - it creates a dataset and stores it as a session for the userwhen im any web page - and cast the session to a dataset - it works... but when I refresh the page - the session is lost.... any ideas why?


View Complete Post


More Related Resource Links

Weird problem with session cookie

  
Hi all,I'm having a weird problem with my web application, and I can't find the solution to it.I'm using a Java applet to read some data from an electronic ID. This applet posts its captured data to a HttpHandler class and stores the data back in some session variables. It all works smoothly, unless in some cases.Every time a do a new publish to the webserver or the website isn't touched for some time. There is a problem with the session.The applet can't find a session cookie, and so it crashes.I did some tests and indeed, the cookie ("ASP.NET_SessionId") does not exists. But it seems that other session variables (user login, etc) are working fine.To make sure that the cookie for the session ID is readable from the applet I do the following in the global.asax: Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs when a new session is started Dim isSessionFound As Boolean = False If Response.Cookies.Count > 0 Then For Each s As String In Response.Cookies.AllKeys If s = "ASP.NET_SessionId" Then Response.Cookies("ASP.NET_SessionId").HttpOnly = False isSessionFound = True 'just for test End If Next End If End SubI tried to do something with the isSessionFound, wh

Weird casting error (storing Generic list in Session)

  

Am trying to store a generic list in Session to act as a simple shopping cart. Am getting a weird casting error when I try and retrieve it from Session.

A critical error has occurred.
[A]System.Collections.Generic.List`1[MyCartItem] cannot be cast to [B]System.Collections.Generic.List`1[MyCartItem].
Type A originates from 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    in the context 'LoadNeither' at location 'C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll'.
Type B originates from 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    in the context 'LoadNeither' at location 'C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll'.


I have a class variable defined:

List<MyCartItem> _cart;

In the Load event I have:

_cart = (Session["MyCart"] != null) ? (List<MyCartItem>)Session["MyCart"] : new List<MyCartItem>();



Weird problem with session cookie

  

Hi all,

I'm having a weird problem with my web application, and I can't find the solution to it.

I'm using a Java applet to read some data from an electronic ID. This applet posts its captured data to a HttpHandler class and stores the data back in some session variables. It all works smoothly, unless in some cases.

Every time a do a new publish to the webserver or the website isn't touched for some time. There is a problem with the session.

The applet can't find a session cookie, and so it crashes.

I did some tests and indeed, the cookie ("ASP.NET_SessionId") does not exists. But it seems that other session variables (user login, etc) are working fine.

To make sure that the cookie for the session ID is readable from the applet I do the following in the global.asax:

    Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' Code that runs when a new session is started
        Dim isSessionFound As Boolean = False
        If Response.Cookies.Count > 0 Then
            For Each s As String In Response.Cookies.AllKeys
                If s = "ASP.NET_SessionId" Then
                    Response.Cookies("ASP.NET_SessionId").HttpOnly = False
                    isSessionFound = True 'just for test
                End If
            Next
        End If
   End Sub


I

MS SQL Server: Disconnect Users From Database - Kill User Session

  
If you ever wanted to restore your database from a SQL backup file (.bak), but there are still users connected to your database, the backup operation will fail causing the error: Exclusive access could not be obtained because the database is in use.

SQL Server Session state problem.

  

Hi to all,


I have some things that I want to know. I am right now using a free asp.net webhosting ("somee.com"). The problem is that when I am visiting a page, there's a tendency that values stored in my session variables are lost. Therefore, it causes an error when the requested page is loaded.

1. I am thinking of using sessionState mode="SqlServer". Will it solve my problem?

Actualy Im working on it but Im having problems when connecting to the sql database.

2.  Is that a problem in the webhost?

3. Do free webhosting sites provide allow session state in the sql server?. Because ive tried it locally into my computer and error say's i should intall the ASP.NET Session State SQL Server version 2.0 or above.




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.


Is there any way to find out the reason for session expiry?

  

Dear All,

is there any way to find out the reason for session expiry?

Regards

Denny


Session time out earlyer with in 5 min.

  

In my live site session time out with in 5 min only.how can i get the default i.e 20 min time . below webconfig file give below



<?xml version="1.0"?>
<!--
    Note: As an alternative to hand editing this file you can use the
    web admin tool to configure settings for your application. Use
    the Website->Asp.Net Configuration option in Visual Studio.
    A full list of settings and comments can be found in
    machine.config.comments usually located in
    \Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
    <configSections>
        <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, &#xA;        System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, &#xA;        PublicKeyToken=31bf3856ad364e35">
            <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, &#xA;        System.Web.Extensions, Ver

Datatable in session

  

I am creating a simple shopping cart using a datatable that is passed into a session object.  I have a small mini cart that displays the total number of items in the cart as well as the running total - this is displayed in a web control.  When the web control starts up I run a try/catch to see if the session object exists, if it doesn't I create the datatable for the cart and store it in the session.  I then have a datalist control that contains all the information for my products including an "add to cart" button.  When the page loads everything looks fine.  If I click on an "add to cart" button nothing happens to the session information.  If I click on it again, the session information updates - displaying only one item is in the cart and then counts up correctly there after.  Additionally, after adding an item, if I select a different item in the list, the same issue occurs.  I am not sure why this is happeing, if anyone can give me an idea I would appreciate it. 


Session

  

Hi friends

I m facing a problem in my application with server so it needs changes .

My question is

Q1.Where should I store my session if i want to disconnect my server or How shold we storesession in web farm if specific serever is shut down.

Q2.Can anyone explain me difference between WEB FARM and WEB GARDEN

 

Regards

Chandrakant

 

 


Session Timeouts

  

What are the issues (if any) of setting sessions to expire after an extended period of time as in 4-8 hours? I'm building an intranet app which is designed so that users will access it once in the morning and then leave it used, possibly, for hours at a time. I'm assuming that there aren't too many since

1) we're running it on a intranet
2) sessions are soley to retain state between requests
3) its not like a connection to the DB where you can conceivable run out


holding datatable value using session

  

Hi,

iam insert record using datable in gridivew,iam using  session to hold the record,

there is any other way to hold the record in datable.

dtempty.Columns.Add("storeid");   
        dtempty.Columns.Add("ratetypeid");
        dtempty.Columns.Add("ratedesc");
        dtempty.Columns.Add("slabs");   
        dtempty.Columns.Add("days");
        dtempty.Columns.Add("rate");
        dtempty.Columns.Add("contid");
        dtempty.Columns.Add("continertype");

        DataRow row;
        row = dtempty.NewRow();
         
        row["ratetypeid"] = ddlratetype.SelectedValue;
        row["ratedesc"] = ddlratetype.SelectedItem.Text;
        row["slabs"] = ddlslabs.SelectedValue;   
 &n

Session with Crystal Reports on IE 8

  

All,

Having a very wierd problem.  I have an application that uses Crystal Reports and it uses what I have found to be a common scenario (I am not a CR expert in any way).  I have an ASPX page that gathers options for the report, and then it goes and gets the data and if there is some, a button appears for them to launch the report.  On clicking that button, the code sets some values in the HttpResponse.Context area, then performs a Server.Transfer to another ASPX page that is our Report Template.  This page contains the CR stuff and it generates a PDF version of the report.  It then does the following code:

 With HttpContext.Current.Response
            .ClearContent()
            .ClearHeaders()
            .ContentType = "application/pdf"
            .AddHeader("Content-Disposition", "inline; filename=Report.pdf")
            .BinaryWrite(s.ToArray)
            .End()
        E

Session problem with display of image in row of reportviewer

  

Hello techies...

I am new to this sql reporting service. But anyhow by surfing I am able to bind the report but i was stuck in image display.

Anyways, i also managed that. But the real problem is whenever i was keeping a image control in rdlc report i was having session prob. If i remove the image control then as usual report works fine.

Please suggest me some solution.... either for session problem or for image display. I am keeping the image name in database but for binding the rdlc report i am using a store procedure which return the path (static) concating with the image name(kept in database).

Hope to find a solution .....


Session handling

  

I am beginner to asp.net. I wanna set up a login page in ASP.NET. I dont like to use ASP.NET's own Login facilities.. I wanna use session object..How will I block visiting "user page" by clicking the back button of the browser after successfull logout 

 

Pls help me..


Best Practices: Fast, Scalable, and Secure Session State Management for Your Web Applications

  

ASP.NET provides a number of ways to maintain user state, the most powerful of which is session state. This article takes an in-depth look at designing and deploying high-performance, scalable, secure session solutions, and presents best practices for both existing and new ASP.NET session state features straight from the ASP.NET feature team.

Mike Volodarsky

MSDN Magazine September 2005


Categories: 
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