Hi Daniil.. thanks for your answer!
Well... I´m not sure that the problem is a session time-out. I set in my webconfig the session time-out to 20 minutes, and the problem occurss few seconds after the application starts.
it seems to me, the problem occurs after an asynchronous request to load or reload of the gridPanel. My source data is a SQL Server 2008, and my Store Proxy is a WebMethod of my WebService.
I created a test project that exemplifies this bug:
A gridPanel bind to a WebService.
The WebService has two methods. One return a ext.net.Paging and other return a session value.
In default.aspx Page_Load, I set in Session a value.
In default.aspx, there are a button. If you click in this button, trigger a function that consumes the WebService1.GetSessionValue. Its work.
The gridPanel is load with values returned by Webservice1... its work to.
If you mark the checkbox to 'Show Session Value in Webservice1.getData when refresh gridPanel', and click in 'refresh' button of bottonbar of gridPanel, in the getData, a code that try get Session value and Show in a Message box is enable. But this code triggers a Null Exception erro when try get Session value.
I know this is not your responsibility, but if you can take a look and tell me if you have any idea, I'll be very grateful...
Follow the Test Project code:
class Customer
Public Class Customer
Private mvarCode As Long
Private mvarName As String
Private mvarBirthDate As Date
Public Sub New()
MyBase.New()
mvarCode = 0
mvarName = ""
mvarBirthDate = #1/1/0900#
End Sub
Public Sub New(pCode As Long, pName As String, pBirthDate As Date)
mvarCode = pCode
mvarName = pName
mvarBirthDate = pBirthDate
End Sub
Public Property Code As Long
Get
Return mvarCode
End Get
Set(value As Long)
mvarCode = value
End Set
End Property
Public Property Name As String
Get
Return mvarName
End Get
Set(value As String)
mvarName = value
End Set
End Property
Public Property BirthDate As Date
Get
Return mvarBirthDate
End Get
Set(value As Date)
mvarBirthDate = value
End Set
End Property
End Class
WebService1
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
<System.Web.Script.Services.ScriptService()>
Public Class WebService1
Inherits System.Web.Services.WebService
<WebMethod()> _
<ScriptMethod()> _
Public Function GetData(start As Long, limit As Long, sort As String, filter As String) As Paging(Of Customer)
Dim vList As List(Of Customer) = New List(Of Customer)
If filter = "True" Then
MsgBox(HttpContext.Current.Session("MySessionValue"))
End If
vList.Add(New Customer(1, "José Roberto", #1/2/1978#))
vList.Add(New Customer(2, "Fabio Zatta", #4/24/1976#))
vList.Add(New Customer(3, "Kelly Esperança", #5/21/1982#))
vList.Add(New Customer(4, "Veríssimo Rizzi", #6/19/1981#))
Return New Ext.Net.Paging(Of Customer)(vList, vList.Count)
End Function
<WebMethod()> _
<ScriptMethod()> _
Public Function GetSessionValue() As String
Return HttpContext.Current.Session("MySessionValue")
End Function
End Class
Default.aspx
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="WebApplication1._Default" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Session.Add("MySessionValue", "This is my Session Value!")
End Sub
Protected Sub ShowSession(sender As Object, e As DirectEventArgs)
Dim vmsg As Ext.Net.MessageBox = New Ext.Net.MessageBox
Dim ws As WebApplication1.WebService1 = New WebApplication1.WebService1
vmsg.Alert("Session Value", ws.GetSessionValue)
vmsg.Show()
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Session NullException</title>
<script type="text/javascript">
function getFilter() {
var sFilter = "0";
sFilter = Session.Test.chkReadSessionValue.getValue();
return sFilter;
}
</script>
</head>
<body>
<ext:ResourceManager ID="resManager1" runat="server" Locale="pt-BR" Namespace="Session.Test"/>
<ext:Panel runat="server" X="5" Y="5" Layout="AbsoluteLayout" Height="400" Width="600">
<Items>
<ext:Button runat="server" id="btnShowSessionValue" text="Show Session Value" x="50" y="5" width="300" heigth="50">
<DirectEvents>
<Click OnEvent="ShowSession" />
</DirectEvents>
</ext:Button>
<ext:Checkbox runat="server" ID="chkReadSessionValue" x="50" Y="30"/>
<ext:DisplayField ID="DisplayField1" runat="server" Text="Show Session Value in Webservice1.getData when refresh gridPanel" x="80" Y="30" Width="400"/>
<ext:GridPanel runat="server" ID="grid1" Title="Customers" Frame="true" Layout="FitLayout" IconCls="icon-sugestoes" ButtonAlign="Right" x="50" Y="50" Width="500" Height="300">
<Store>
<ext:Store ID="Store1" runat="server" RemoteSort="true" PageSize="10">
<Proxy>
<ext:AjaxProxy Json="true" Url="~/WebService1.asmx/GetData">
<ActionMethods Read="POST" />
<Reader>
<ext:JsonReader Root="d.Data" TotalProperty="d.TotalRecords" />
</Reader>
</ext:AjaxProxy>
</Proxy>
<AutoLoadParams>
<ext:Parameter Name="start" Value="0" Mode="Raw" />
<ext:Parameter Name="limit" Value="10" Mode="Raw" />
</AutoLoadParams>
<Parameters>
<ext:StoreParameter Name="filter" Value="getFilter()" Mode="Raw" />
</Parameters>
<Model>
<ext:Model runat="server" IDProperty="Code" ID="ctl10">
<Fields>
<ext:ModelField Name="Code" />
<ext:ModelField Name="Name" />
</Fields>
</ext:Model>
</Model>
<Sorters>
<ext:DataSorter Property="Code" Direction="DESC" />
</Sorters>
</ext:Store>
</Store>
<ColumnModel runat="server" ID="columnmodel1">
<Columns>
<ext:Column runat="server" Text="ID" DataIndex="Code" Width="75px" Sortable="true" />
<ext:Column runat="server" ID="Name" Text="Name" DataIndex="Name" Width="400px" Sortable="true" />
</Columns>
</ColumnModel>
<BottomBar>
<ext:PagingToolbar ID="tbPagingSugestoes" runat="server" DisplayInfo="true"
DisplayMsg="List {0} - {1} of {2}" EmptyMsg="No records">
<Items>
<ext:Label ID="Label1" runat="server" Text="Page Size:" />
<ext:ToolbarSpacer runat="server" Width="10" />
<ext:ComboBox ID="cmbPageSize" runat="server" Width="80">
<Items>
<ext:ListItem Text="5" />
<ext:ListItem Text="10" />
<ext:ListItem Text="15" />
<ext:ListItem Text="20" />
<ext:ListItem Text="25" />
<ext:ListItem Text="30" />
</Items>
<SelectedItems>
<ext:ListItem Value="10" />
</SelectedItems>
<Listeners>
<Select Handler="#{grid1}.store.pageSize = parseInt(this.getValue(), 10); #{grid1}.store.load({params:{start:0}});" />
</Listeners>
</ext:ComboBox>
</Items>
</ext:PagingToolbar>
</BottomBar>
</ext:GridPanel>
</Items>
</ext:Panel>
</body>
</html>