ServerVariables("LOGON_USER") reports a length greater than the characters displayed

Discussion in 'ASP .Net' started by Ryan, Jan 19, 2006.

  1. Ryan

    Ryan Guest

    I am trying to figure out why


    I am trying to use the result of Request.ServerVariables("LOGON_USER")
    in a query in my aspx application. I want to use the server variable.
    When I check the length of the string that this method returns
    (len(Request.ServerVariables("LOGON_USER")) I get a number that is one
    greater than the the number of characters that are displaying, which of
    course causes a problem. Does anyone know why this is and how to fix
    the problem. My only guess is that it is counting the slash even
    though it does not display it...

    e.g.

    LOGIN: MyDomain\Ryan
    Request.ServerVariables("LOGON_USER") = MyDomainRyan
    len(Request.ServerVariables("LOGON_USER") = 13
    len("MyDomainRyan") = 12

    Thanks,
    Ryan
    Ryan, Jan 19, 2006
    #1
    1. Advertising

  2. Ryan

    Ryan Guest

    Re: ServerVariables("LOGON_USER") reports a length greater than the characters displayed

    Ok, so I found the answer to my own question. In case anyone is
    wondering I feel like I should explain what went wrong, though I am
    reluctant to admit it...

    I was viewing the server variable by outputting the text to a
    javascript alert box. And of course, when javascript saw the special
    character "\" it treated it as such and hence what displayed was
    different than the actual variable value.

    Ryan wrote:
    > I am trying to figure out why
    >
    >
    > I am trying to use the result of Request.ServerVariables("LOGON_USER")
    > in a query in my aspx application. I want to use the server variable.
    > When I check the length of the string that this method returns
    > (len(Request.ServerVariables("LOGON_USER")) I get a number that is one
    > greater than the the number of characters that are displaying, which of
    > course causes a problem. Does anyone know why this is and how to fix
    > the problem. My only guess is that it is counting the slash even
    > though it does not display it...
    >
    > e.g.
    >
    > LOGIN: MyDomain\Ryan
    > Request.ServerVariables("LOGON_USER") = MyDomainRyan
    > len(Request.ServerVariables("LOGON_USER") = 13
    > len("MyDomainRyan") = 12
    >
    > Thanks,
    > Ryan
    Ryan, Jan 19, 2006
    #2
    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. T.
    Replies:
    7
    Views:
    15,762
    RiaanBod
    Apr 28, 2011
  2. Amitava Bardhan
    Replies:
    1
    Views:
    2,866
    Marina
    May 17, 2005
  3. =?Utf-8?B?THluZXJz?=
    Replies:
    0
    Views:
    1,372
    =?Utf-8?B?THluZXJz?=
    Dec 5, 2005
  4. Replies:
    1
    Views:
    1,543
    Göran Andersson
    Nov 29, 2008
  5. Jeff Cochran
    Replies:
    2
    Views:
    440
    Jeff Cochran
    Jan 9, 2006
Loading...

Share This Page