ASP code displaying blank page

I'm currently registering users according to the below criteria:

If rsUser.recordCount > 0 Then
Response.Cookies("adminID")      = rsUser("adminID")
Response.Cookies("adminName")      = rsUser("adminName")
Response.Redirect "../main.asp"
Else
Response.Redirect "../loginFailure.asp"
End If

I need to put another condition like this:

If user AccessLevel = '0' then response.redirect main1.asp
If user AccessLevel = '1' then response.redirect main2.asp

I tried to incorporate the code inside main.asp, like below, but it doesn't work (it gives a blank page)

<% if session("AccessLevel")="1" then
response.redirect = "main1.asp"
elseif session("AccessLevel")="0" then
response.redirect = "main2.asp"            
end if %>

What am I doing wrong?
The code can also be incorporated inside main.asp. I tried but that also gives a blank page.



LVL 5
zamorinAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tirandaganCommented:
It looks like you forgot to set the session variable ("AccessLevel").
I assume your login validation should contain something like:

session("AccessLevel") = rsUser("AccessLevel")

Because from the example you provided,  session("accessLevel") is not being set, so is = NULL, so both conditions fail and what you are left with is the rest of the main.asp file, which is nothing (ego, blank page)
0
zamorinAuthor Commented:
Where do I set it?
0
zamorinAuthor Commented:
I tried this, but it doesn't work:

      If rsUser.recordCount > 0 Then
            Response.Cookies("adminID")                  = rsUser("adminID")
            Response.Cookies("adminName")            = rsUser("adminName")
            Response.Cookies("AccessLevel")            = rsUser("AccessLevel")
            Response.Redirect "../main.asp"
      Else
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

weddellCommented:
You have
response.redirect = "main2.asp"

try

response.redirect("main2.asp")
0
weddellCommented:
<%

If Session("AccessLevel")="1" Then
    Response.Redirect("main1.asp")
ElseIf Session("AccessLevel")="0" Then
    Response.Redirect("main2.asp")
Else
    Response.Write("this isn't a blank page")
End If

%>

All Zamorin meant about setting it is that it isn't assigned a value in the script you posted...

So above the condition you write

Session("AccessLevel") = 1 ' or get this from the database

Response.Redirect is a method not a property, therefore = should not be included

Ciao.
0
zamorinAuthor Commented:
Now if I login with AccessLevel 1 or 0 it displays the message:
this isn't a blank page

Do I have to set Session("AccessLevel")  somewhere?

The AccessLevel is retreived from the database.
0
weddellCommented:
yes.. you have to set it to the database value... see below where rsUser("adminLevel") is your column name in the database (ensure it's coming back in your SQL statement as well)

If rsUser.recordCount > 0 Then
    Response.Cookies("adminID") = rsUser("adminID")
    Response.Cookies("adminName") = rsUser("adminName")
    Session("AccessLevel") = rsUser("adminLevel")

    If Session("AccessLevel") = "1" Then
        Response.Redirect("main1.asp")
    ElseIf Session("AccessLevel") = "0" Then
        Response.Redirect("main2.asp")
    Else
        Response.Write("no admin level was found")
        Response.End
    End If

Else
    Response.Redirect("../loginFailure.asp")
End If
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
zamorinAuthor Commented:
Works perfectly!
0
weddellCommented:
Thanks for the points and comment. For your info, this script is a little more refined and may be useful if you add more access levels later:

Dim pagePath

' Login Failure Page
pagePath = "../loginFailure.asp"

If rsUser.recordCount > 0 Then

      Response.Cookies("adminID") = rsUser("adminID")
      Response.Cookies("adminName") = rsUser("adminName")
      Session("AccessLevel") = rsUser("adminLevel")

      Select Case Trim(Session("AccessLevel"))
            Case "0"
                  ' Standard Membership
                  pagePath = "../main2.asp"
            Case "1"
                  ' Premium Membership
                  pagePath = "../main1.asp"
      End Select

End If

Response.Redirect(pagePath)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.