newbie/noob question. request querystring in a .vb

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • .nLL

    newbie/noob question. request querystring in a .vb

    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.Alp haNumOnly(Reque st.QueryString( "un"))
    Dim MyPw As String = MyFunctions.Alp haNumOnly(Reque st.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

    #2
    Re: newbie/noob question. request querystring in a .vb

    to make it clear, here is my class

    --------------
    Public Class MyFunctions
    Public Shared Function CheckLogin(ByVa l 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(MyPw Input) & "'"
    Dim Conn As New OleDbConnection (MyDbPath)
    Dim Cmd As New OleDbCommand(My Sql, Conn)
    Conn.Open()
    MyResult = Cmd.ExecuteScal ar
    Conn.Close()
    Return MyResult
    End Function
    End Class
    ----------------------


    how can i write so, instead of MyUnInput,MyPwI nput i can call
    request.queryst ring("un"),requ est.querystring ("pw")



    ".nLL" <noone@here.com wrote in message
    news:UT9Gk.3433 2$0D6.359@newsf e01.ams2...
    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.Alp haNumOnly(Reque st.QueryString( "un"))
    Dim MyPw As String =
    MyFunctions.Alp haNumOnly(Reque st.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
    >
    >
    >

    Comment

    • bruce barker

      #3
      Re: newbie/noob question. request querystring in a .vb

      create a global.asa and add:

      void Application_Aut horizeRequest(o bject 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(ByVa l 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(MyPw Input) & "'"
      Dim Conn As New OleDbConnection (MyDbPath)
      Dim Cmd As New OleDbCommand(My Sql, Conn)
      Conn.Open()
      MyResult = Cmd.ExecuteScal ar
      Conn.Close()
      Return MyResult
      End Function
      End Class
      ----------------------
      >
      >
      how can i write so, instead of MyUnInput,MyPwI nput i can call
      request.queryst ring("un"),requ est.querystring ("pw")
      >
      >
      >
      ".nLL" <noone@here.com wrote in message
      news:UT9Gk.3433 2$0D6.359@newsf e01.ams2...
      >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.Al phaNumOnly(Requ est.QueryString ("un"))
      > Dim MyPw As String =
      >MyFunctions.Al phaNumOnly(Requ est.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
      >>
      >>
      >>
      >

      Comment

      • .nLL

        #4
        Re: newbie/noob question. request querystring in a .vb

        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" <nospam@nospam. comwrote in message
        news:up71LqzJJH A.3444@TK2MSFTN GP02.phx.gbl...
        create a global.asa and add:
        >
        void Application_Aut horizeRequest(o bject 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(ByVa l 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(MyPw Input) & "'"
        > Dim Conn As New OleDbConnection (MyDbPath)
        > Dim Cmd As New OleDbCommand(My Sql, Conn)
        > Conn.Open()
        > MyResult = Cmd.ExecuteScal ar
        > Conn.Close()
        > Return MyResult
        > End Function
        >End Class
        >----------------------
        >>
        >>
        >how can i write so, instead of MyUnInput,MyPwI nput i can call
        >request.querys tring("un"),req uest.querystrin g("pw")
        >>
        >>
        >>
        >".nLL" <noone@here.com wrote in message
        >news:UT9Gk.343 32$0D6.359@news fe01.ams2...
        >>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.A lphaNumOnly(Req uest.QueryStrin g("un"))
        >> Dim MyPw As String =
        >>MyFunctions.A lphaNumOnly(Req uest.QueryStrin g("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
        >>>
        >>>
        >>>
        >>

        Comment

        • s.foschi@gmail.com

          #5
          Re: newbie/noob question. request querystring in a .vb

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

          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

          Comment

          Working...