Forms Form Verification

xiaoxiao2021-03-05  22

Copy the following code in the existing application's global.asax file, assign these characters to the authentication user in the Application_AuthenticateRequest event handler: Sub Application_AuthenticateRequest (Byval EVENTARGS) IF (NOT (httpcontext.current. User is nothing) Thenif httpContext.current.user.Identity.AuthenticationType = "forms" thendim id as system.Web.security.FormSidentityId = httpContext.current.user.Identity

Dim myroles (2) as stringmyroles (0) = "manager" myroles (1) = "admin" httpContext.current.user = new system.security.principal.GenericPrincipal (ID, myroles) End IFEND IFEND SUB Back to top Check users Roles and Program Logic in the ASPX page The following steps describes how to implement and control program logic depending on the role belonging to the validation user. 1. Create a new .aspx page named Sample.aspx, and paste the following code: <% @ page language = "VB"%> <% @ Import namespace = "system.Web"%>