newbie/noob question. request querystring in a .vb

Discussion in 'ASP .Net' started by .nLL, Oct 5, 2008.

  1. .nLL

    .nLL Guest

    Hi, im am a classic asp developer and started to learn asp.net but got stuck
    with a simple problem even before i step in to further.

    to learn i have started from a simple project (a login system with forms)
    due to projects platform (a mobile web site) i cant use cookies (cookies
    arent supported on all phones), anyway because of that i do un/pw check on
    very page and i have to put

    Dim MyUn As String = MyFunctions.AlphaNumOnly(Request.QueryString("un"))
    Dim MyPw As String = MyFunctions.AlphaNumOnly(Request.QueryString("pw"))

    to every page. In classic asp i could create an include and put smilar code
    to get un/pw but in asp.net (VB) i couldnt figureout how to. I ahve got my
    functions.vb where i store shared functions and variables but could put
    above in to it.
    could anyone point me to right direction?
    thanks
     
    .nLL, Oct 5, 2008
    #1
    1. Advertising

  2. .nLL

    .nLL Guest

    to make it clear, here is my class

    --------------
    Public Class MyFunctions
    Public Shared Function CheckLogin(ByVal MyUnInput As String, ByVal
    MyPwInput As String) As String
    Dim MyResult As Integer
    Dim MySql As String
    MySql = "Select count(*) from users where un='" & MyUnInput & "' and
    pw='" & MD5Encrypt(MyPwInput) & "'"
    Dim Conn As New OleDbConnection(MyDbPath)
    Dim Cmd As New OleDbCommand(MySql, Conn)
    Conn.Open()
    MyResult = Cmd.ExecuteScalar
    Conn.Close()
    Return MyResult
    End Function
    End Class
    ----------------------


    how can i write so, instead of MyUnInput,MyPwInput i can call
    request.querystring("un"),request.querystring("pw")



    ".nLL" <> wrote in message
    news:UT9Gk.34332$2...
    > Hi, im am a classic asp developer and started to learn asp.net but got
    > stuck with a simple problem even before i step in to further.
    >
    > to learn i have started from a simple project (a login system with forms)
    > due to projects platform (a mobile web site) i cant use cookies (cookies
    > arent supported on all phones), anyway because of that i do un/pw check on
    > very page and i have to put
    >
    > Dim MyUn As String =
    > MyFunctions.AlphaNumOnly(Request.QueryString("un"))
    > Dim MyPw As String =
    > MyFunctions.AlphaNumOnly(Request.QueryString("pw"))
    >
    > to every page. In classic asp i could create an include and put smilar
    > code to get un/pw but in asp.net (VB) i couldnt figureout how to. I ahve
    > got my functions.vb where i store shared functions and variables but could
    > put above in to it.
    > could anyone point me to right direction?
    > thanks
    >
    >
    >
     
    .nLL, Oct 5, 2008
    #2
    1. Advertising

  3. .nLL

    bruce barker Guest

    create a global.asa and add:

    void Application_AuthorizeRequest(object sender, EventArgs e)
    {
    // call by validation code here
    }


    note: while shared functions are ok, shared variables (or public module
    variables) are shared across all requests.

    -- bruce (sqlwork.com)

    ..nLL wrote:
    > to make it clear, here is my class
    >
    > --------------
    > Public Class MyFunctions
    > Public Shared Function CheckLogin(ByVal MyUnInput As String, ByVal
    > MyPwInput As String) As String
    > Dim MyResult As Integer
    > Dim MySql As String
    > MySql = "Select count(*) from users where un='" & MyUnInput & "'
    > and pw='" & MD5Encrypt(MyPwInput) & "'"
    > Dim Conn As New OleDbConnection(MyDbPath)
    > Dim Cmd As New OleDbCommand(MySql, Conn)
    > Conn.Open()
    > MyResult = Cmd.ExecuteScalar
    > Conn.Close()
    > Return MyResult
    > End Function
    > End Class
    > ----------------------
    >
    >
    > how can i write so, instead of MyUnInput,MyPwInput i can call
    > request.querystring("un"),request.querystring("pw")
    >
    >
    >
    > ".nLL" <> wrote in message
    > news:UT9Gk.34332$2...
    >> Hi, im am a classic asp developer and started to learn asp.net but got
    >> stuck with a simple problem even before i step in to further.
    >>
    >> to learn i have started from a simple project (a login system with
    >> forms) due to projects platform (a mobile web site) i cant use cookies
    >> (cookies arent supported on all phones), anyway because of that i do
    >> un/pw check on very page and i have to put
    >>
    >> Dim MyUn As String =
    >> MyFunctions.AlphaNumOnly(Request.QueryString("un"))
    >> Dim MyPw As String =
    >> MyFunctions.AlphaNumOnly(Request.QueryString("pw"))
    >>
    >> to every page. In classic asp i could create an include and put smilar
    >> code to get un/pw but in asp.net (VB) i couldnt figureout how to. I
    >> ahve got my functions.vb where i store shared functions and variables
    >> but could put above in to it.
    >> could anyone point me to right direction?
    >> thanks
    >>
    >>
    >>

    >
     
    bruce barker, Oct 5, 2008
    #3
  4. .nLL

    .nLL Guest

    old habits die hard, isn't there any other option to do it? i dont want to
    use global.asa or web.config. reason is that i want to be able to put
    project in any folder on my server without having setup an appliaciton on
    iis for it. that way it is portable and can be moved without any setup on
    web server



    "bruce barker" <> wrote in message
    news:...
    > create a global.asa and add:
    >
    > void Application_AuthorizeRequest(object sender, EventArgs e)
    > {
    > // call by validation code here
    > }
    >
    >
    > note: while shared functions are ok, shared variables (or public module
    > variables) are shared across all requests.
    >
    > -- bruce (sqlwork.com)
    >
    > .nLL wrote:
    >> to make it clear, here is my class
    >>
    >> --------------
    >> Public Class MyFunctions
    >> Public Shared Function CheckLogin(ByVal MyUnInput As String, ByVal
    >> MyPwInput As String) As String
    >> Dim MyResult As Integer
    >> Dim MySql As String
    >> MySql = "Select count(*) from users where un='" & MyUnInput & "'
    >> and pw='" & MD5Encrypt(MyPwInput) & "'"
    >> Dim Conn As New OleDbConnection(MyDbPath)
    >> Dim Cmd As New OleDbCommand(MySql, Conn)
    >> Conn.Open()
    >> MyResult = Cmd.ExecuteScalar
    >> Conn.Close()
    >> Return MyResult
    >> End Function
    >> End Class
    >> ----------------------
    >>
    >>
    >> how can i write so, instead of MyUnInput,MyPwInput i can call
    >> request.querystring("un"),request.querystring("pw")
    >>
    >>
    >>
    >> ".nLL" <> wrote in message
    >> news:UT9Gk.34332$2...
    >>> Hi, im am a classic asp developer and started to learn asp.net but got
    >>> stuck with a simple problem even before i step in to further.
    >>>
    >>> to learn i have started from a simple project (a login system with
    >>> forms) due to projects platform (a mobile web site) i cant use cookies
    >>> (cookies arent supported on all phones), anyway because of that i do
    >>> un/pw check on very page and i have to put
    >>>
    >>> Dim MyUn As String =
    >>> MyFunctions.AlphaNumOnly(Request.QueryString("un"))
    >>> Dim MyPw As String =
    >>> MyFunctions.AlphaNumOnly(Request.QueryString("pw"))
    >>>
    >>> to every page. In classic asp i could create an include and put smilar
    >>> code to get un/pw but in asp.net (VB) i couldnt figureout how to. I ahve
    >>> got my functions.vb where i store shared functions and variables but
    >>> could put above in to it.
    >>> could anyone point me to right direction?
    >>> thanks
    >>>
    >>>
    >>>

    >>
     
    .nLL, Oct 5, 2008
    #4
  5. .nLL

    Guest

    one thing:
    this is not the right way:
    MySql = "Select count(*) from users where un='" & MyUnInput & "' and
    pw='" & MD5Encrypt(MyPwInput) & "'"

    use parameters! this way up here you will have trouble with
    sqlinjection.

    >that way it is portable and can be moved without any setup on web server


    I am curious the way you are developing...
    in my idea: just put global.asax and web.config in the root folder of
    the website using the asp.net page, and is done, what else?
    I mean web.config is required.

    Simone Foschi
    MCTS Sql Server 2005
     
    , Oct 8, 2008
    #5
    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. Daniel Bass
    Replies:
    2
    Views:
    3,778
    dave wanta
    Jul 4, 2003
  2. George
    Replies:
    5
    Views:
    6,684
    George
    Apr 2, 2004
  3. michaaal
    Replies:
    6
    Views:
    438
    Michael D. Kersey
    Jul 15, 2003
  4. John Davis
    Replies:
    2
    Views:
    427
    Dave Anderson
    Aug 18, 2003
  5. Ivan
    Replies:
    5
    Views:
    171
Loading...

Share This Page