Forum Discussion

Christopher_Kei's avatar
Christopher_Kei
Icon for Nimbostratus rankNimbostratus
May 23, 2006

iRule to Persist based on ASP.NET Session ID

I am trying to create an iRule that will force traffic to persist to the same server based on the ASP.NET_SessionId cookie that the application inserts. I do not want the BigIP to insert its own cookie. Is there a way to do this? Here's the rule that I am working with:

 

 

when HTTP_REQUEST {

 

if { [HTTP::cookie exists "ASP.NET_SessionId"] } {

 

persist uie [HTTP::cookie "ASP.NET_SessionId"] }

 

}

 

 

 

Thanks.

 

 

Chris

3 Replies

  • We were given the following iRule by F5, but it is not working correctly.

     

     

    when HTTP_REQUEST {

     

    set SessionId [HTTP::cookie ASP.NET_SessionId]

     

    log local0. "Request SessionId is: $SessionId"

     

    if { $SessionId != "" } { persist uie $SessionID }

     

    }

     

    when HTTP_RESPONSE {

     

    set SessionId [findstr [HTTP::cookie names] "ASP.NET_SessionId" 18 24]

     

    log local0. "Response SessionId is: $SessionId"

     

    if { $SessionId != "" }{ persist add uie $SessionId }

     

    }

     

     

    We added this iRule to a Universal persistance profile. Now when we browse to the application, images are not being displayed. When we log into the application, we get a page cannot be displayed error.

     

     

    Any ideas/suggestions would be great.

     

     

    Thanks.

     

     

    Chris

     

  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    This rule did work with only a single cookie being set by the server.

     

     

    Follow-up post here requesting insight on extracting one of multiple cookies set by the server: Click here

     

     

    /d
  • Deb_Allen_18's avatar
    Deb_Allen_18
    Historic F5 Account
    If you don't mind, let's work your other thread, since you've included a better problem description there:

     

    http://devcentral.f5.com/default.aspx?tabid=28&view=topic&forumid=5&postid=10331

     

    Click here

     

     

    /deb