When using MobileControls in .Net 2.0 it seems whenever a user's session times out and they do a post back they get the error:
The page requires session state that is no longer
available. Either the session has expired, the client did not send a
valid session cookie, or the session state history size is too small.
Try increasing the history size or session expiry limit.
If I disable viewstate for the page this error won't happen but I get other errors when asp.net tries to re-bind the values of drop downs.
To reproduce this issue create Default.aspx with
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<mobile:Form ID="MainForm" Runat="server">
<mobile:SelectionList ID="EndPoint" SelectType="DropDown" Runat="server" BreakAfter="true">
<Item Text="Test1" Value="test1" />
<Item Text="Test2" Value="test2" />
mobile:SelectionList>
<mobile:Command ID="TestPost" Runat="server" OnClick="TestPost_Click" BreakAfter="True">TestPostmobile:Command>
mobile:Form>
body>
html>
Default.aspx.cs with:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Mobile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.MobileControls;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.MobileControls.MobilePage
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void TestPost_Click(object sender, EventArgs e)
{
}
}
and web.config with:
<configuration>
<appSettings />
<connectionStrings />
<system.web>
<compilation debug="false" />
<authentication mode="Windows" />
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
customErrors>
<httpRuntime useFullyQualifiedRedirectUrl="true" />
<mobileControls cookielessDataDictionaryType="System.Web.Mobile.CookielessData" />
<deviceFilters>
<filter name="isJPhone" compare="Type" argument="J-Phone" />
<filter name="isHTML32" compare="PreferredRenderingType" argument="html32" />
<filter name="isWML11" compare="PreferredRenderingType" argument="wml11" />
<filter name="isCHTML10" compare="PreferredRenderingType" argument="chtml10" />
<filter name="isGoAmerica" compare="Browser" argument="Go.Web" />
<filter name="isMME" compare="Browser" argument="Microsoft Mobile Explorer" />
<filter name="isMyPalm" compare="Browser" argument="MyPalm" />
<filter name="isPocketIE" compare="Browser" argument="Pocket IE" />
<filter name="isUP3x" compare="Type" argument="Phone.com 3.x Browser" />
<filter name="isUP4x" compare="Type" argument="Phone.com 4.x Browser" />
<filter name="isEricssonR380" compare="Type" argument="Ericsson R380" />
<filter name="isNokia7110" compare="Type" argument="Nokia 7110" />
<filter name="prefersGIF" compare="PreferredImageMIME" argument="image/gif" />
<filter name="prefersWBMP" compare="PreferredImageMIME" argument="image/vnd.wap.wbmp" />
<filter name="supportsColor" compare="IsColor" argument="true" />
<filter name="supportsCookies" compare="Cookies" argument="true" />
<filter name="supportsJavaScript" compare="Javascript" argument="true" />
<filter name="supportsVoiceCalls" compare="CanInitiateVoiceCall" argument="true" />
deviceFilters>
system.web>
configuration>
Then browse to Default.aspx, click the button, clear your cookies and session variables and click the button again and you'll get the error. Any help would be appreciated.