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

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

Session Ending or FormsAuthentication problem after the browser tab closing

Posted By:      Posted Date: October 09, 2010    Points: 0   Category :ASP.Net

In my project user logs in the site with login.aspx page. Then user is redirecting to homepage (anasayfa.aspx)

User close the browser tab (not the browser) then user tries to open the site again and the page is default.aspx

Default.aspx is useless in my project. Host area needs a default.aspx, index.html like something and I added this default aspx.

I want:

After user close the browser tab, if he/she wants to open the site again, the first page must be his/her homepage not default.aspx

I didn't use asp.net membership provider or anything like that.

This is my login.aspx page code:

protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        SqlConnection con = new SqlConnection();
        con.ConnectionString = cnnstr;
        SqlCommand cmd = con.CreateCommand();
        cmd.CommandText = "Select Roles,UserId,UserName,Sifre,AccountType From ProfilBilgileri Where UserName = @txtLoginUserName AND Sifre = @txtLoginSifre and Durum=1";
        cmd.Parameters.Add("@txtLoginUserName", SqlDbType.NVarCh

View Complete Post

More Related Resource Links

Session expiry on closing browser window

The article Session expiry on closing browser window was added by RustyIron on Saturday, February 26, 2011.

Ever wondered what occurs when a user closes his browser window. For the time, the user was interacting with a site, his session was active and everything was going smooth.But how does our player ("Server" , here) come to know that a user has

WebDev.WebServer.exe has encounted a problem and needs to close when trying to view page in browser


Hi, whenever I load an aspx page in vwde2008, I get the message in the subject of this post.  After I click Ok on that, I get a dialog box, Unable to Connect to the ASP.Net development center.  What can I do to troubleshoot?

I am using Windows XP SP3, vwde2008 with SP1, on a HP desktop.  Also using Office 2003 if that is relevant at all.

Thanks, Justin

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

Problem with Session and PageMethod


Hi All,

I'm trying to show some data in the update panel refreshing every second using page method. Everything works fine until I introduce Session. As soon as I save some data into the session my Ajax Page method is not called every second. Here is the complete code


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script type="text/javascript" language="JavaScript">
        function UpdateStatus() {
            setTimeout("UpdateStatus()", 1000);

        function ShowStatus(sCurrentStatus) {
            document.getElementById('lblStatus').innerHTML = sCurrentStatus;
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True&q

Session Problem with IE 6 and IFrames


hi folks

i've a problem with session objects in my asp .net 2.0 webapplication. when i open my webapplication in a IFRAME and IE, it doesn't work, because my session object is NOTHING.

what's wrong ? what can i do ?

Kind regards

Session State Problem




I just for the first time into a session state problem. So I am hoping someone

here has the answer.


I have written an ASP.Net website and tried to implement the common poor mans online user count.
The problem I am having is the following.

On App_Start I create a variable and assign it the value of 0;

Then increase the number on session_start and decrement on session_end.

On my local IIS it works perfectly from IE8 and Opera. The value increments correctly.
As soon as I upload to my live server. The value increments on every link I click and every page refresh when I test with IE8.
This does not happen when testing with Opera.

Could someone please shed some light on the subject.




Louis Lews

session lost problem


hi there,

i have an application that uses sessions.

i have set at the web.config: 

<forms loginUrl="Default.aspx" protection="All" timeout="30" name=".ASPXFAUTH" path="/" requireSSL="false" slidingExpiration="true" defaultUrl="Default.aspx" cookieless="UseCookies" enableCrossAppRedirects="true"/>

and at the global.asax.vb

Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
        Session.Timeout = 30

end Sub

and at default.aspx.vb

Protected Sub LoginButton_Click(ByVal sender As Object, ByVal e As EventArgs)
        Session("userName") = Login1.UserName
        Session.Timeout = 30 ' minutes of session '

    End Sub

At a local iis on windows xp works fine,

but when i publish it at the webserver i am redirected to the default page after about 30 sec!!!

any ideas?


problem in css for Mozilla browser



I am displaying data in crystal report and I want to data to be displayed in vertical format. I am getting the proper alignment in all the bowsers ie. IE,chrome and safari. But having the problem with Mozilla.

The problem is with text alignment with any symbol eg. (% of hours), I want to display it in a single vertical line. But when a symbol is encountered (here it is %), it is displaying that in the next line.

Can anyone help me on this ? Its urgent.

Please find my CSS below.

    font-family:Arial,Verdana, Geneva, Helvetica, sans-serif;
    font-size: 10px;  
    -moz-transform: rotate(-45deg);
    -moz-transform-origin: 70px 55px;




Common session for different browser instance


Hello everyone,

I am working on a website which uses a common database shared by another 2-3 websites.  Now i am having a requirement that whenever a user clicks a link provided on another website and comes to my website and if the user is already logged in to my website then my website should not ask him to login again it should by pass the login page and show the next page.

Here the problem is i am not able to get the session objects in newly opened browser window even if the user is already logged in to my website in another browser window. I am not sure but i thing IE uses two different processes for two different browser instance and because of that i am not getting the session objects required.

Deos anyone have some idea on my problem.

Note: I can not ask the another website vendor to pass anything as a querystring.

Problem with ASP.NET Ajax, Framework version 4.0 and the SeaMonkey browser...

I have a site that I'm upgrading to the 4.0 framework and I've come across an issue with asp.net ajax and the SeaMonkey browser. It seems like the script manager is not registering the scripts on the page in seamonkey (but it works fine in IE, Firefox, Chrome, Opera, and Safari). Now, if I change the user agent string in SeaMonkey to use the user agent string from any of those other browsers, it works fine. So I guess my question is does ASP.NET Ajax check the browser's user agent to determine what scripts to register and, if so, is it possible that SeaMonkey is not included in the list in the 4.0 framework (I should add that it's working fine in the 3.5 framework so it seems to me like this is a difference between the two framework versions).

Problem with closing window in ie 6 sp 3 after download using Response.BinaryWrite

Hi all, I currently having problems in closing a page that launches a download (using Response.BinaryWrite) opened using IE 6 sp 3. All other versions of IE it closes fine. This page was opened using window.open. Below is a sample code of what i am trying to achieve: protected void Page_Load(object sender, EventArgs e) { Response.Clear(); //Specify the document type. Response.ContentType = "application/word"; //Specify how the document is sent to the browser. Response.AddHeader("content-disposition", "attachment; filename=MyDasddsaocument.doc"); //Get data bytes from the file and send it to the response. byte[] bytes = System.IO.File.ReadAllBytes(@"C:\\Temp\\in.doc"); Response.BinaryWrite(bytes); Response.End(); Page.ClientScript.RegisterStartupScript(this.GetType(), "CloseMe", "window.close();", true); } I hope someone can help me with this issue. Thank you in advance.

Ajax Session timeout problem

Hi,  I have some problems when using AJAX with updatepanels. I have an ASP.NET webapplication with a login that uses form authentication with the timeout set to 5 min. After 5 min of idle the site should be redirected to the login.aspx page. My problem is that after using the site for 5 minutes when clicking on contents inside an updatepanel I get a messagebox with the following error: A Runtime Error has occurred.Do you wish to Debug? Line: 4723Error: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 12031  I think that it has something to do with the ajax updatepanel since when I remove the updatpanels this problem does not appear. Instead the site is redirected to login.aspx as expected. When searching on the problem on google I see alot of people having similar problem, but I haven't found suitable solution. Any suggestions?

Is this problem of browser(IE7)

0 down vote favorite This is the dynamic example jsFiddle dynamic DEMO CLICK ME and This is static example jsFiddle static DEMO CLICK ME When I load markup dynamically into div it is not working in IE7. But if it is static it works fine. Yesterday I was unable to state my problem clearly so I made this fiddle. Please check it out and reply.

problem in join two pages with session

hi every body I have two web pages one for inbox messages and second for details for one message in first page I have gridview include name the sender , address the message and details message alongside with buttonfield to go  to another page to view  full message the code of gridview<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlDataSource1" Width="648px" onrowcommand="GridView1_RowCommand"> <Columns> <asp:BoundField DataField="sender" HeaderText="sender" SortExpression="sender" /> <asp:BoundField DataField="address" HeaderText="address" SortExpression="address" /> <asp:BoundField DataField="details" HeaderText="details" SortExpression="details" /> <asp:ButtonField Text="More..." CommandName="Show_More" /> <asp:TemplateField ShowHeader="False"> <ItemTemplate> </ItemTemplate>

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

AutoCompleteExtender ContextKey with Session Problem

I have a aspx page with an AutoCompleteExtender and I retrieve users from database.While user log in, I get user's id from database and set to Session["iduser"]. I want to use Session["iduser"] as a contextkey in AutoCompleteExtender. I tried different ways for this but it didn't work...Also I am using a updatepanel.<asp:ScriptManager ID="ScriptManager1" runat="server">    <Services>     <asp:ServiceReference Path="WebService.asmx" />    </Services>    </asp:ScriptManager>my source code:<asp:TextBox ID="txtPost" runat="server"  CssClass="form_text_ozellik"         BackColor="Transparent" BorderStyle="None"></asp:TextBox>     <cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="txtPost" ServicePath="WebService.asmx" ServiceMethod="GetUsers"   MinimumPrefixLength="1" CompletionSetCount="12"  DelimiterCharacters="," UseContextKey="true" CompletionInterval="200" EnableCaching="true">    </cc1:AutoCompleteExtender>my web service code:[We
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