Browser History Problem

Last post 04-25-2008 1:09 AM by sujoyupadhyay. 17 replies.

Sort Posts:

  • Sad [:(] Browser History Problem

    03-28-2008, 7:52 PM
    • Loading...
    • wsyeager
    • Joined on 06-26-2002, 7:42 PM
    • Weston, Florida, USA
    • Posts 435

    I'm using IE 7 to run a simple test from page1 to page2 and back again wanting to see if the form data comes back on page1 for the controls.

    I'm using VS 2008 and created an ASP.Net 3.5 Extensions Website. I'm storing the state in a HistoryPoint, but when I go back to page1, I don't even hit the breakpoint at the ScriptManager.Navigate event.

    I have the UpdateMode set to Conditional on the UpdatePanel; a trigger set up for the ScriptManager control on the Navigate event; have EnableHistory set to True on the ScriptManager.

    If I could send a zip file of this tiny project here, I would. But, I really need help with this one. I'm tearing my hair out on it. I've tried everything I can think of. I thought maybe it was my web.config file (not having the right extensions, etc), so I removed it and added a clean one.

    Here is my web.config file:

    <code>

    <?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, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
       <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
        <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
        <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
         <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
         <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
         <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
         <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
        </sectionGroup>
       </sectionGroup>
       <section name="dynamicData" type="System.Web.DynamicData.DynamicDataControlsSection" requirePermission="false" allowDefinition="MachineToApplication"/>
      </sectionGroup>
     </configSections>
     <appSettings/>
     <connectionStrings/>
     <system.web>
      <!--
                Set compilation debug="true" to insert debugging
                symbols into the compiled page. Because this
                affects performance, set this value to true only
                during development.
        -->
      <compilation debug="true">
       <assemblies>
        <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
        <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
       </assemblies>
      </compilation>
      <!--
                The <authentication> section enables configuration
                of the security authentication mode used by
                ASP.NET to identify an incoming user.
        -->
      <authentication mode="Windows"/>
      <!--
                The <customErrors> section enables configuration
                of what to do if/when an unhandled error occurs
                during the execution of a request. Specifically,
                it enables developers to configure html error pages
                to be displayed in place of a error stack trace.

            <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
                <error statusCode="403" redirect="NoAccess.htm" />
                <error statusCode="404" redirect="FileNotFound.htm" />
            </customErrors>
        -->
      <pages>
       <controls>
        <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add tagPrefix="asp" namespace="System.Web.UI.SilverlightControls" assembly="System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add tagPrefix="asp" namespace="System.Web.DynamicData" assembly="System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
        <add tagPrefix="asp" tagName="DynamicFilter" src="~/App_Shared/DynamicDataFields/FilterUserControl.ascx"/>
       </controls>
      </pages>
      <httpHandlers>
       <remove verb="*" path="*.asmx"/>
       <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
       <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
       <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
      </httpHandlers>
      <httpModules>
       <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
       <add name="DynamicDataModule" type="System.Web.DynamicData.DynamicDataHttpModule, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
       <add name="UrlRoutingModule" type="System.Web.Mvc.UrlRoutingModule, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      </httpModules>
     </system.web>
     <system.codedom>
      <compilers>
       <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <providerOption name="CompilerVersion" value="v3.5"/>
        <providerOption name="WarnAsError" value="false"/>
       </compiler>
       <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <providerOption name="CompilerVersion" value="v3.5"/>
        <providerOption name="OptionInfer" value="true"/>
        <providerOption name="WarnAsError" value="false"/>
       </compiler>
      </compilers>
     </system.codedom>
     <system.web.extensions>
      <!--
            <dynamicData
                // Type of the data context to be used
                dataContextType="[type]"
                enableTemplates="[bool]"  // whether to enable templates or not
                >
           
              <mappings
                queryStringKeyPrefix=""   // the prefix used for query string parameter keys
                pattern=""           // the pattern used in forming paths. must contains {table} and {viewName} identifiers
                >
                <add
                  actions="list|details" // can be comma-separated list
                  viewName=""       // string used in path pattern.
                  templateFile=""     // template to use if actual file does not exist. File path relative to App_PageTemplates
                  tables="[table names]"  // make these settings only apply to a list of tables (can be a comma-separated list)
                  path=""          // override the default path generated from the pattern. must be app relative
                  />
              </mappings>
            </dynamicData
        -->
      <dynamicData dataContextType="" enableTemplates="false">
       <mappings queryStringKeyPrefix="" pattern="~/{table}/{viewName}.aspx">
        <add actions="list,details" viewName="ListDetails" templateFile="ListDetailsTemplate.aspx"/>
        <!--
              <add actions="list" viewName="List" templateFile="ListTemplate.aspx" />
              <add actions="details" viewName="Details" templateFile="DetailsTemplate.aspx" />
            -->
        <!--
              Special overriding cases
              <add actions="list,details" tables="Products,Categories" viewName="SpecialName" templateFile="ListTemplate.aspx"/>
              <add actions="list" tables="Products" templateFile="DetailsTemplate.aspx" path="~/customPath.aspx"/>
              <add actions="list" tables="Orders" viewName="MyListViewName"/>
            -->
       </mappings>
      </dynamicData>
     </system.web.extensions>
     <!--
            The system.webServer section is required for running ASP.NET AJAX under Internet
            Information Services 7.0.  It is not necessary for previous version of IIS.
      -->
     <system.webServer>
      <validation validateIntegratedModeConfiguration="false"/>
      <modules runAllManagedModulesForAllRequests="true">
       <remove name="ScriptModule"/>
       <remove name="DynamicDataModule"/>
       <remove name="UrlRoutingModule"/>
       <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
       <add name="DynamicDataModule" preCondition="managedHandler" type="System.Web.DynamicData.DynamicDataHttpModule, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
       <add name="UrlRoutingModule" type="System.Web.Mvc.UrlRoutingModule, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      </modules>
      <handlers>
       <remove name="WebServiceHandlerFactory-Integrated"/>
       <remove name="ScriptHandlerFactory"/>
       <remove name="ScriptHandlerFactoryAppServices"/>
       <remove name="ScriptResource"/>
       <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
       <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
       <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
       <add name="MvcScriptMap" preCondition="classicMode" verb="*" path="*.mvc" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll"/>
       <add name="MvcHandler" preCondition="integratedMode" verb="*" path="Mvc.axd" type="System.Web.Mvc.MvcHandler, System.Web.Extensions, Version=3.6.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      </handlers>
     </system.webServer>
     <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
       <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-3.5.0.0" newVersion="3.6.0.0"/>
       </dependentAssembly>
       <dependentAssembly>
        <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-3.5.0.0" newVersion="3.6.0.0"/>
       </dependentAssembly>
      </assemblyBinding>
     </runtime>
    </configuration>

    </code>

    Here is the HTML for Page1 (the page I'm having a problem with not hitting the Navigate event breakpoint I have set):

    <code>

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

    <!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">
        <title>Page 1</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
       
        </div>
        <asp:ScriptManager ID="ScriptManager1" runat="server"
            EnableHistory="True">
        </asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
                <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
    <asp:AsyncPostBackTrigger ControlID="ScriptManager1" EventName="Navigate"></asp:AsyncPostBackTrigger>
            </Triggers>
        </asp:UpdatePanel>
        <asp:Button ID="Button1" runat="server" Text="Button" />
        </form>
    </body>
    </html>

    </code>

    Here is the code-behind for Page1:

    Imports System.Collections.Specialized.NameValueCollection

    Partial Class _Default
        Inherits System.Web.UI.Page

        Private clsAuthors As clsPageHistory.Author

        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

            Try
                If (ScriptManager1.IsInAsyncPostBack) And (Not ScriptManager1.IsNavigating) Then 'In process of restoring state and not creating a new one
                    clsAuthors = New clsPageHistory.Author
                    clsAuthors.AuthorId = TextBox1.Text
                    clsAuthors.FirstName = TextBox2.Text
                    clsAuthors.LastName = TextBox3.Text
                    Dim colAuthors As New NameValueCollection(clsPageHistory.Author.AddAuthorCollection(clsAuthors))
                    ScriptManager1.AddHistoryPoint(colAuthors, "HPDefault")
                    colAuthors = Nothing
                End If
            Catch ex As Exception
                Response.Write("error 1")
            End Try

            Response.Redirect("page2.aspx?Text1=" & TextBox1.Text & "&Text2=" & TextBox2.Text & "&Text3=" & TextBox3.Text)

        End Sub

        Protected Sub ScriptManager1_Navigate(ByVal sender As Object, ByVal e As System.Web.UI.HistoryEventArgs) Handles ScriptManager1.Navigate

            Try
                If e.State.HasKeys Then
                    Dim colAuthors As New NameValueCollection(e.State)
                    If colAuthors("CollectionName") = "Authors" Then
                        TextBox1.Text = colAuthors("AuthorId")
                        TextBox2.Text = colAuthors("FirstName")
                        TextBox3.Text = colAuthors("LastName")
                        Page.Title = "Default"
                    End If
                    colAuthors = Nothing
                End If
            Catch ex As Exception
                Response.Write("error 2")
            End Try

        End Sub

    End Class

    </code>

    Note that I'm only having a problem with the Navigate event. It is storing the state just fine. When I'm on page2 and click back, the Navigate event isn't hit.

    If you need any more code in relation to this project, please let me know. I would appreciate knowing what's going on because I plan to use this concept in a business project at work. If I can't get the history to work, no use using AJAX.

    Thanks so much in advance....

    Thanks,

    Bill Yeager MCP.Net, BCIP
  • Re: Browser History Problem

    03-31-2008, 4:31 AM
    • Loading...
    • Razr
    • Joined on 12-20-2006, 8:53 PM
    • Posts 9

     How do you mean 'When I hit back', do you mean the back button in your webbrowser? I wasn't able to figure this one out because you didn't post your page2 source.
     

  • Re: Browser History Problem

    03-31-2008, 12:10 PM
    • Loading...
    • wsyeager
    • Joined on 06-26-2002, 7:42 PM
    • Weston, Florida, USA
    • Posts 435

    Yes... I meant hitting the Back button in my browser.

    Page2 is really insignificant. It only consists of 3 textboxes which receive the querystring values from page1.

    Thanks,

    Bill Yeager MCP.Net, BCIP
  • Re: Browser History Problem

    04-01-2008, 3:02 AM
    • Loading...
    • Razr
    • Joined on 12-20-2006, 8:53 PM
    • Posts 9

     I see, i thought i had a answer but i was wrong (never used the navigate event). But maybe this link can be of some help? :

     http://bytes.com/forum/thread775505.html
     

  • Re: Browser History Problem

    04-02-2008, 7:24 PM
    • Loading...
    • wsyeager
    • Joined on 06-26-2002, 7:42 PM
    • Weston, Florida, USA
    • Posts 435

    Thanks... At least someone responded. I'm so surprised that no Microsoft personnel has responded to this thread. It's a very simple problem, but with huge benefits (if it works).....

    I sent an email to the person via the link you sent hoping he might be ble to respond to the link knowing what might be going on...

    Thanks,

    Bill Yeager MCP.Net, BCIP
  • Re: Browser History Problem

    04-19-2008, 2:07 PM
    • Loading...
    • wsyeager
    • Joined on 06-26-2002, 7:42 PM
    • Weston, Florida, USA
    • Posts 435

    Does anybody have an explanation about this issue explained more in detail at the following link:

    http://www.codeproject.com/KB/aspnet/ajaxhistorymanagement.aspx?msg=2514710#xx2514710xx

     

    Thanks,

    Bill Yeager MCP.Net, BCIP
  • Re: Browser History Problem

    04-19-2008, 8:25 PM
    • Loading...
    • scottgal
    • Joined on 02-26-2008, 6:56 AM
    • Seattle, WA
    • Posts 10
    • AspNetTeam

    Hi, let me direct this to someone on our team who should be able to give some advice on this...

  • Re: Browser History Problem

    04-20-2008, 1:11 PM
    • Loading...
    • wsyeager
    • Joined on 06-26-2002, 7:42 PM
    • Weston, Florida, USA
    • Posts 435

    Thank you so much. I would really appreciate that...

    If you need any other info, just let me know and I'll be glad to supply it. The way the History works now, it is just not going to "cut it" in a real world scenario.

    Thanks,

    Bill Yeager MCP.Net, BCIP
  • Re: Browser History Problem

    04-21-2008, 1:24 PM
    • Loading...
    • bleroy
    • Joined on 04-12-2003, 7:09 AM
    • Redmond
    • Posts 2,247

    That's because of the redirect. Why do you need to redirect?

    If you're going to navigate away from the page, you don't need the Ajax history feature: you can just use the querystring to manage and restore state.

    Bertrand
    ----
    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Browser History Problem

    04-21-2008, 2:18 PM
    • Loading...
    • roman_t
    • Joined on 04-21-2008, 5:36 PM
    • Ukraine
    • Posts 6

    Hello. I also have strange browser history problem which can be reproduced under IE6/IE7.

    You probably saw History control example: http://quickstarts.asp.net/Futures/ajax/doc/history.aspx.

     It works perfectly under IE and FireFox. But try this: copy first demo source code (http://quickstarts.asp.net/Futures/util/srcview.aspx?path=~/ajax/samples/history1.src) to newly created ASP.Net 3.5 Extensions Website. Run this example in Internet Explorer (I used IE 7.0). Click all three buttons ('1', '2', '3') with 1 second interval. Notice navigation history items, there are four of them: Current Page + three items for each button click. Now navigate to some other web site (type http://www.google.com for example in your address bar and hit enter). Look at navigation history once more, only two items are present, all  three records from our page collapsed to one which points to the last page's state. But this is not a problem. Click Back button. Collapsed record expanded back and now we have five history items. This is the behavior I expect

    And now interesting part. Add to ButtonClick method next line of code

     ScriptManager.RegisterStartupScript(this, GetType(), "hmmm", "", true);  
    Do all described steps from scratch. After you click Back button you'll see only two (not five) history items. Why??? What the magic is hidden inside ScriptManager.RegisterStartupScript()? It is the biggest problem with web history management inside IE which I cannot solve. I'll be very grateful for any help.
    P.S. If modify web.config file and change <compilation debug="true"> to <compilation debug="false"> this will resolve described problem, but only described simple case. Such "fix" does not resolve this problem in web site which I am writing where AJAX controls extenders are present inside UpdatePanel .

     

     

  • Re: Browser History Problem

    04-21-2008, 2:44 PM
    • Loading...
    • wsyeager
    • Joined on 06-26-2002, 7:42 PM
    • Weston, Florida, USA
    • Posts 435

    I posted another comment at the following url which explains why this is happening:

     

    http://www.codeproject.com/KB/aspnet/ajaxhistorymanagement.aspx?msg=2516760#xx2516760xx

    Thanks,

    Bill Yeager MCP.Net, BCIP
  • Re: Browser History Problem

    04-22-2008, 6:19 AM
    • Loading...
    • roman_t
    • Joined on 04-21-2008, 5:36 PM
    • Ukraine
    • Posts 6

    Thanks for reply. But I still do not understand why FireFox maintain all History records after navigating to differ page and then back, and Internet Explorer forgets them. In fact I do not use MS History control, I use my own one which suffer from similar problem. Later I investigated that MS History control also has such a problem. I suppose the main reason of this 'bug' is that hidden IFRAME is used to maintain history under IE, so when we go away from our page all History Items which are owned by IFRAME disappears. They appear after I click Back and navigate to page with this hidden IFRAME - but they do not appear if ScriptManager.RegisterStartupScript() was called during SOME async postback. It is a mystery which I still do not comprehend

  • Re: Browser History Problem