Session variables between asp.net and classic

Last post 11-10-2009 9:32 AM by troyrowlands1976. 3 replies.

Sort Posts:

  • Session variables between asp.net and classic

    11-09-2009, 8:42 AM

    I am new to asp.net and have never used classic asp. My .net application uses ASP.net membership. I would like to attatch a forum written on classic asp using ASP.net membership credentials.

    So, what I need to do, after reading a few articles, is write the asp membership credentials to a SQL DB in my ASP.net application and then retrieve them in classic ASP and put them into session variables which can then be used by the forum application.

    I have done the 1st part but now need to retrieve the credentials from SQL using classic ASP. Please help. My code for putting the credentials into the DB is as follows:

     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Session("USER") = User.Identity.Name
            Dim username As String = Session("USER")
            Dim u As MembershipUser = Membership.GetUser(username, False)
            Dim password As String
            Dim emailad As String = Membership.GetUser("required_Username").Email
    
            password = u.GetPassword()
            Session("PASSWORD") = password
            Session("EMAIL") = emailad
            
    
            Dim accmd As New SqlCommand()
            Dim cn As New SqlConnection
    
    
            'SQL data conxn to db
    
            cn.ConnectionString = ConfigurationManager.ConnectionStrings("LocalSqlServer").ConnectionString
    
    
            ' Run SQL Command
    
            With accmd
    
                .CommandText = "insert into Tempcred (username, password, email) values ('" & username & "' , '" & password & "', '" & emailad & "')"
                .Connection = cn
                .Connection.Open()
                .ExecuteNonQuery()
                .Connection.Close()
                .Dispose()
    
            End With
    
    
        End Sub


    Please could someone give me the code for getting the variable out of the DB in classic ASP.

    Thanks in advance

  • Re: Session variables between asp.net and classic

    11-09-2009, 10:15 AM
    Answer
    • All-Star
      77,676 point All-Star
    • jeff@zina.com
    • Member since 09-26-2003, 10:43 AM
    • Naples, FL, USA
    • Posts 10,562
    • Moderator
      TrustedFriends-MVPs

    troyrowlands1976:
    I would like to attatch a forum written on classic asp using ASP.net membership credentials.
     

    This isn't going to be easy.  You'll likely need to store session info in cookies, then rewrite the classic ASP app to handle them.  You may be better off moving to an ASP.NET forum.

    Jeff

    Blatant Self Promotion: ASP.NET 3.5 CMS Development
  • Re: Session variables between asp.net and classic

    11-09-2009, 10:28 AM

    On the surface it seems very easy, just write a bit of code that gets values from a sql db and puts them into a session. Is this difficult in classic asp? The forum i'm using is Web Wiz Forums (http://www.webwizguide.com/webwizforums/). The reason I chose this is that it intergrates easily with ASP.net membership. So the User does not have to log in twice. It simply takes the credentials from sesssion variables.

    I am open to suggestions if you know of other free forums that can be easily implemented into my ASP.NET application. As I said, I am new to asp so any help is very much appreciated.

    Thanks

     

  • Re: Session variables between asp.net and classic

    11-10-2009, 9:32 AM

    As Jeff mentioned above, I have got around this by passing the sessions via a cookie from Classic ASp to ASP.net. I scrapped the SQL idea. The cookie method seems to work ok. 

Page 1 of 1 (4 items)