We help IT Professionals succeed at work.

Redirect a page based off of persmissions

kdeutsch
kdeutsch asked
on
201 Views
Last Modified: 2010-04-14
I created a simple persmissions event that checks if someone was added to a a permissions database.
Whiel if gives them a response.write you do not have persmissions to view this page.  i want to add on to it to show this message and then redirect them to another page.  Follwoing is my code for page load and then the main code from my common file.
page Load
If checkAdmin() = False Then
            Response.Write("You do not have permission to view this page!")
            Response.End()
        End If

Common file code tha is called.
Public Shared Function checkAdmin() As Boolean
        Dim userLogon = Split(Current.User.Identity.Name, "\")(1)

        sql = "select intAdminID from tblAdmin where intAdminID = (select intID from WORSDotNet.dbo.tblUser " _
            & "where strLogon = '" & userLogon & "')"

        myDataTable = New DataTable
        myDataTable = getData(sql)

        If myDataTable.Rows.Count = 0 Then
            checkAdmin = False
        Else
            checkAdmin = True
        End If
    End Function

Comment
Watch Question

Cem TürkSenior Software Engineer

Commented:

If checkAdmin() = False Then
            Response.Write("You do not have permission to view this page!")
Response.Write("<meta HTTP-EQUIV=""refresh"" content=0;url=""login.asp"">"
            Response.End()
        End If

Open in new window

Author

Commented:
Hi,
I get a Blue underline under the last  quote that says          ')' Expected
I tried putting in a Parentethis and different ways but to no avial.
Cem TürkSenior Software Engineer

Commented:
sorry small typo over there
If checkAdmin() = False Then
            Response.Write("You do not have permission to view this page!")
Response.Write("<meta HTTP-EQUIV=""refresh"" content=0;url=""login.asp"">")
            Response.End()
        End If

Open in new window

Author

Commented:
HI,
Ok it builds but it does not redirect to another page, I chagned the url to mine and it does not work??
Maybe somehting i am dong wrong.
 If checkAdmin() = False Then
            Response.Write("You do not have permission to view this page!")
            Response.Write("")
            Response.End()
        End If
Senior Software Engineer
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Ok, see how it works.  I reworked the number as well to 3 seconds to give them time to view the message.  Thanks for the help.
Cem TürkSenior Software Engineer

Commented:
your welcome

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.