Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7785983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:20:36+00:00 2026-06-01T20:20:36+00:00

I have seen several posts online complaining that Firefox maintains the history url hash

  • 0

I have seen several posts online complaining that Firefox maintains the history url hash after redirecting.. That is the behavior I am hoping for – and it happens in Firefox (11.0), Chrome (18.0), and Opera (11.61), but not IE (9) or Safari (5.1.2).

On my page, I have ASP.NET 4.0 history points set up and working (has been working for a couple years). I also pass a few querystring params to the page. What I am trying to do now is check the value of a new querystring param, and if it does not match what I am expecting, redirect to the same page with an updated value. I am using this mechanism to track the session of individual tabs of a browser so that when they have the same page open in multiple tabs, the session values dont step on each other from tab to tab.

Anyway, I have everything working correctly including the back/forward using ASP.NET History points – and when I visit a bookmark and the querystring param does not match, I redirect and change the querystring param to track the session, and the history state that is in the url of the bookmark is then used to reload the page to the state I want. But that only works in Firefox, Chrome, and Opera. Not IE which is the big one for me (based solely on our user base), and not Safari.

I have identified that in addition to (or perhaps because of) the fact that the url history state is not present, ScriptManager.Navigate is not called after the redirect in IE or Safari.

Is there a setting/option that I can set on the ScriptManager or during the redirect to maintain the History state in the url? If the history state was in the url, I could call ScriptManager.Navigate directly if I needed to, but the values are not present in the url.

If it helps at all, here’s a listing of where I do the check and redirect. The ReportRunID is then appended to the session variable keys that need to be unique to each tab. I keep a listing of previous ReportRunIDs to keep track and to clean them out (after a certain time period, or when more than [MAX] ids are encountered) so that I dont overload server memory with these session entries.

Private Sub Page_PreInit(sender As Object, e As System.EventArgs) Handles Me.PreInit

    If IsPostBack = False Then
        Dim rrid As String = Request.QueryString("RRID")
        If ReportRunIDExists(rrid) = False Then
            ReportRunID = Now.ToString("_HHmmssfff")
            Dim url As String = Request.Url.PathAndQuery

            If String.IsNullOrEmpty(rrid) Then
                Response.Redirect(String.Format("{0}&RRID={1}", url, _reportRunID))
            Else
                Dim idx As Integer = url.IndexOf("&RRID=")
                Response.Redirect(String.Format("{0}&RRID={1}{2}", url.Substring(0, idx), _reportRunID, url.Substring(idx + 6 + rrid.Length)))
            End If
        End If
    End If

End Sub

Private Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
    'save current RRID/Page/Time to session
    UpdateSessionReportRunID(_reportRunID)
End Sub

…

If my bookmarked url looks like:

mysite.com/mypage.aspx?Rpt=123&RRID=_095224678#&&state1=abc&state2=def...

In FF/Chrome/Opera after the redirect, my url looks like:

mysite.com/mypage.aspx?Rpt=123&RRID=_102176253#&&state1=abc&state2=def...

But in IE/Safari after redirect, my url looks like:

mysite.com/mypage.aspx?Rpt=123&RRID=_102176253

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:20:37+00:00Added an answer on June 1, 2026 at 8:20 pm

    After much more searching, I have come to the realization that History State hash is not sent to the server. It is stored in the querystring so that it is included in bookmarks, but it is accessed by the client-side scriptmanager which causes a postback to load the state values. Since the Server never sees the hash value in the querystring, I have no way of finding those values when a user follows a bookmark to that page.

    This problem was introduced as I was trying to start tracking the session state of different browser tabs individually. In my code above, if the RRID parameter is empty or invalid, I have to redirect to self with a new RRID value. When I do that redirect the History State hash was being lost for IE and Safari (but not for the other browsers).

    My workaround:

    The problem is that I needed to include the hash value in my redirect, but that is not available from the server, so I decided to inject some javascript to the page to perform the redirect from the client where the hash is available.

    I already had a Client Redirect extension helper method that I have used in different scenarios, and I modified it to include the current hash value:

    <System.Runtime.CompilerServices.Extension()>
    Public Sub ClientRedirect(ByVal Response As HttpResponse, ByVal url As String, Optional ByVal target As Target = Nothing, Optional ByVal windowFeatures As String = Nothing, Optional includeCurrentHash As Boolean = False)
    
        If IsNothing(target) Then
            If windowFeatures = String.Empty Then
                target = ResponseHelper.Target._self
            Else
                target = ResponseHelper.Target._blank
            End If
        End If
    
        Dim page As Page = CType(HttpContext.Current.Handler, Page)
        url = page.ResolveClientUrl(url)
    
        Dim script As String
        script = "window.open(""{0}"", ""{1}"", ""{2}"");"
    
        script = String.Format(script, url & If(includeCurrentHash, "#"" + window.location.hash + """, String.Empty), target.ToString, windowFeatures)
        If target = ResponseHelper.Target._self Then
            'execute after page has loaded
            page.ClientScript.RegisterStartupScript(GetType(Page), "Redirect_" & Now.ToString("HHmmssfff"), script, True)
        Else
            'execute as page is loading
            page.ClientScript.RegisterClientScriptBlock(GetType(Page), "Redirect_" & Now.ToString("HHmmssfff"), script, True)
        End If
    
    End Sub
    

    Then in my Page_PreInit where I do the redirects, I changed that to do the ClientRedirect including the current hash, and that has gotten the desired result:
    Redirecting the browser while maintaining the History State hash on all browsers.

        'redirect from the client so that we keep the History State URL hash 
        Response.ClientRedirect(String.Format("{0}&RRID={1}", Request.Url.PathAndQuery, _reportRunID), , , True)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen several posts on how to dismiss a dialog by clicking on
I have seen several posts similar to this but none with a strait forward
I have seen several apps that make use of a UISplitViewController inside a tab.
Where is the TickCount() call? I have seen several threads on the web that
What does the Linux /proc/meminfo Mapped topic mean? I have seen several one-liners that
I've seen several posts that essentially state that UI components shouldn't run as a
I have seen several other posts with similar questions but nothing exactly like what
I have seen several posts on the subject, but seems like there is little
I have seen several posts here about cocos2d-android, so ambition to get more idea
I have seen posts like Declaring Multiple Variables in JavaScript that focus on unique

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.