IF Statement - HELP !!

Discussion in 'ASP General' started by Jerry Yang, Sep 7, 2008.

  1. Jerry Yang

    Jerry Yang Guest

    IPADDRESS = Request.ServerVariables("remote_addr")
    response.write IPADDRESS

    Can someone advise how I do this

    If IPADDRESS is not one of 3 addrress then response.redirect
    "notallowed.html"

    I had thought

    if IPADDRESS <> "xxx.xxx.xxx.xxx" OR IPADDRESS <> "yyy.yyy.yyy.yyy" OR
    IPADDRESS "aaa.aaa.aaa.aaa" then response.redirect "notallowed.html"

    but that fails !!

    Help Thanks
     
    Jerry Yang, Sep 7, 2008
    #1
    1. Advertising

  2. Jerry Yang

    daddywhite Guest

    if IPADDRESS <> "xxx.xxx.xxx.xxx" AND IPADDRESS <> "yyy.yyy.yyy.yyy"
    AND
    IPADDRESS "aaa.aaa.aaa.aaa" then response.redirect "notallowed.html"

    Use "AND" instead of "OR"
     
    daddywhite, Sep 7, 2008
    #2
    1. Advertising

  3. "Jerry Yang" <> wrote in message
    news:...
    > IPADDRESS = Request.ServerVariables("remote_addr")
    > response.write IPADDRESS
    >
    > Can someone advise how I do this
    >
    > If IPADDRESS is not one of 3 addrress then response.redirect
    > "notallowed.html"
    >
    > I had thought
    >
    > if IPADDRESS <> "xxx.xxx.xxx.xxx" OR IPADDRESS <> "yyy.yyy.yyy.yyy" OR
    > IPADDRESS "aaa.aaa.aaa.aaa" then response.redirect "notallowed.html"
    >
    > but that fails !!
    >

    Fails In what way. I take it the missing <> in the third clause is simply a
    typo?

    Had you considered simply using the IIS manager and adding the IP address
    restrictions to the file in the properties dialog?


    --
    Anthony Jones - MVP ASP/ASP.NET
     
    Anthony Jones, Sep 7, 2008
    #3
  4. Jerry Yang

    Evertjan. Guest

    Anthony Jones wrote on 07 sep 2008 in
    microsoft.public.inetserver.asp.general:

    > "Jerry Yang" <> wrote in message
    > news:..
    > .
    >> IPADDRESS = Request.ServerVariables("remote_addr")
    >> response.write IPADDRESS
    >>
    >> Can someone advise how I do this
    >>
    >> If IPADDRESS is not one of 3 addrress then response.redirect
    >> "notallowed.html"
    >>
    >> I had thought
    >>
    >> if IPADDRESS <> "xxx.xxx.xxx.xxx" OR IPADDRESS <> "yyy.yyy.yyy.yyy"
    >> OR IPADDRESS "aaa.aaa.aaa.aaa" then response.redirect
    >> "notallowed.html"
    >>
    >> but that fails !!
    >>

    > Fails In what way. I take it the missing <> in the third clause is
    > simply a typo?
    >
    > Had you considered simply using the IIS manager and adding the IP
    > address restrictions to the file in the properties dialog?


    IPADDRESS <> "a" OR IPADDRESS <> "b"

    This is always true,
    as IPADDRESS cannot be two different things/strings at the same time.

    Try AND.


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Sep 7, 2008
    #4
    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:
    3
    Views:
    823
  2. Jay McGavren
    Replies:
    11
    Views:
    1,169
    Alan Krueger
    Jan 16, 2006
  3. tedsuzman
    Replies:
    2
    Views:
    7,149
    Michel Claveau, résurectionné d'outre-bombe inform
    Jul 21, 2004
  4. Ted
    Replies:
    1
    Views:
    486
    Duncan Booth
    Jul 22, 2004
  5. Replies:
    21
    Views:
    1,079
    Giannis Papadopoulos
    Aug 2, 2005
Loading...

Share This Page