Session becomes nothing when machine address is given

Discussion in 'ASP .Net' started by sasidar.d@gmail.com, Mar 10, 2006.

  1. Guest

    hi techies

    I have created a Login web page . It gets the user identity using the
    window nt authetication.
    The page is working fine. I have removed the allow anonymous access
    check box for the virtual directory and then given the check for the
    integrated window authetication.

    After deploying the project in the testing server - windows 2003 server
    (server called as svr10) it is working fine.

    But when deployed in the production server which has the same windows
    2003 server with iis 6.0 i face the following problem

    when i give the url as localhost followed by the virtualdirectory name
    and login.aspx , the i am able to login in

    But i am not able to login when i give the name of the machine instead
    of localhost.

    Similarly i am not able to login from the client system also. the
    client system is windows 2000 professional with ie 6

    After debugging the application i found that the session which i have
    used to store the user identity is becoming nothing after post back

    The sequence of my code is like this

    1) Page load - I retrieve the user identity and store it in a session -
    display the same user identity in the text box.
    2) Button click event - i am checking for the session and then allowing
    to log in, but it fails because the session is nothin

    <code snippet>

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
    System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here
    Try
    If Not Page.IsPostBack Then
    Me.lblstatus.InnerText = "Post back occured "
    Session("UserID") = getLoginDomainUser()
    Me.txtUserID.Value = Session("UserID")
    End If

    Catch ex As Exception
    Me.lblstatus.InnerText = ex.Message
    End Try
    End Sub

    Private Sub btnLogin_ServerClick(ByVal sender As System.Object,
    ByVal e As System.EventArgs) Handles btnLogin.ServerClick
    Try
    If Not Session("UserID") Is Nothing Then
    If Me.txtUserID.Value = Session("UserID").ToString Then
    Me.lblstatus.InnerText &= "Logged Successfully"
    Else
    Me.lblstatus.InnerText &= "Login Failed "
    End If
    Else
    Me.lblstatus.InnerText &= "Session Empty "
    End If

    Catch ex As Exception
    Me.lblstatus.InnerText = ex.Message
    End Try
    End Sub
    Private Function getLoginDomainUser() As String
    Dim strUser As String
    Dim intPos As Int16
    Try

    strUser = User.Identity.Name 'With Domain Name

    If strUser.Trim <> "" Then
    Me.lblstatus.InnerText = Me.lblstatus.InnerText
    intPos = Convert.ToInt16(InStr(strUser, "\"))
    domainName = Mid(strUser, 1, intPos - 1)
    loggedUser = Mid(strUser, intPos + 1)
    getLoginDomainUser = loggedUser
    Else
    Throw New Exception(" Authenctication Not Set. Please
    Contact Administrator ")
    End If
    Catch ex As Exception
    Throw ex
    End Try

    End Function
    <code snippet>

    Not able to find the reason for this peculiar behaviour

    Any help is highly appreciated


    Thanks
     
    , Mar 10, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    2,290
  2. Sam

    Session variable becomes null

    Sam, Jan 31, 2007, in forum: ASP .Net
    Replies:
    5
    Views:
    3,952
    =?Utf-8?B?RWFnbGVSZWRASGlnaEZseWluZ0JpcmRzLmNvbQ==
    Apr 24, 2007
  3. Replies:
    9
    Views:
    1,009
    Juha Nieminen
    Aug 22, 2007
  4. Stef Mientki

    and becomes or and or becomes and

    Stef Mientki, May 22, 2011, in forum: Python
    Replies:
    9
    Views:
    324
    Chris Angelico
    May 28, 2011
  5. Devin Jeanpierre
    Replies:
    2
    Views:
    494
    Devin Jeanpierre
    Feb 14, 2012
Loading...

Share This Page