-1

in _PageStart.[vb/cs]html how to prevent to running requested page?

example:

in _PageStart you check the roles of authenticated user and if is not in your special role, a message shown instead of running page?

my code in _PageStart.vbhtml

@Code
If Roles.IsUserInRole("admin") Or Roles.IsUserInRole("users") Then
    RunPage()
Else
    @RenderPage("~/wtools/_inlineError.vbhtml", "401")
End If
End Code
PurTahan
  • 789
  • 8
  • 24

1 Answers1

1

Reverse condition, and remove else part

If Not Roles.IsUserInRole("admin") And Not Roles.IsUserInRole("users") Then
    Response.StatusCode = 401
    Response.Redirect("~/wtools/_inlineError.vbhtml", True)
End If
Boguslaw
  • 130
  • 8