Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2004
    Location
    Vancouver
    Posts
    17

    Unanswered: using an IF ELSE to response.redirect

    Hi folks. i am taking a stab in the dark here:
    I run an intranet and on my asp pages i capture the userID of the person visiting my web page, using <%
    Userid=mid(Request.ServerVariables ("LOGON_USER"),5)
    %>
    at the top of my pages

    Is there anyway i can use an IF, ELSE function so that if a userID = xxxx then response.redirect to xxxx.asp else response.redirect yyy.asp?

    I am thinking something like:
    Code:
    if ("userid")=ID1, ID2, ID3 then
    	response.redirect "page1.asp"
    
    else
    	response.redirect "page2.asp"
    		
    end if
    All i need is a simple .asp page to redirect the user to another page, based soley on their userid i capture at the top of the page usinf <%
    Userid=mid(Request.ServerVariables ("LOGON_USER"),5)
    %>

    I need it to look at multiple userid's as shown above ie ID1,ID2 etc

    any help?
    thanks
    still in the baby steps of coding

  2. #2
    Join Date
    Dec 2003
    Posts
    454
    If userID = d1 Then
    response.redirect "page1.asp"
    ElseIf userID = D2 Then
    response.redirect "page2.asp"
    ElseIf userID = D3 Then
    response.redirect "page3.asp"
    End If

  3. #3
    Join Date
    Feb 2004
    Location
    Bristol, UK
    Posts
    2
    I am not sure what the VB method but in JScript I would use the switch command. for example:

    switch (userID)
    {
    case "rt1":Response.Redirect("xxx.asp");break;
    case "de1":Response.Redirect("zzzzz.asp");break;
    default:Response.Redirect("sssss.asp");break;
    }

  4. #4
    Join Date
    Dec 2003
    Posts
    454
    In ASP, we use

    Select Case testexpression
    [Case expressionlist-n
    [statements-n]] . . .
    [Case Else
    [elsestatements-n]]
    End Select

    Here is the link for the reference from Microsoft

    http://msdn.microsoft.com/library/de...statements.asp

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •