Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) If Not IsPostBack Then If Request.IsAuthenticated Then Dim ident As FormsIdentity = CType(User.Identity, FormsIdentity) If ident IsNot Nothing Then Dim ticket As FormsAuthenticationTicket = ident.Ticket Dim userDataString As String = ticket.UserData Dim userDataPieces() As String = userDataString.Split("|".ToCharArray()) Dim username As String = userDataPieces(1) Dim rolename As String = userDataPieces(2) If rolename <> "Graduate" Then Response.Redirect("~/login.aspx", False) End If End If Else Response.Redirect("~/login.aspx", False) End If lblerror.Visible = False Dim ident1 As FormsIdentity = CType(User.Identity, FormsIdentity) Dim ticket1 As FormsAuthenticationTicket = ident1.Ticket Dim userDataString1 As String = ticket1.UserData Dim userDataPieces1() As String = userDataString1.Split("|".ToCharArray()) Dim userid As Integer = userDataPieces1(0) Dim ds As DataSet sqlquery("select offer.offerid as 'Offer ID', companyname + '(' + convert(varchar(50), company.companyid) + ')' as 'Company', request.requestid as 'Request ID', fname + ' ' + lname as 'Student', days as 'Days', minsalary as 'Minimum Salary', maxsalary as 'Maximum Salary' from company, offer, request, requestdetail, users where offer.offerid = requestdetail.offerid and offer.companyid = company.companyid and offer.userid = '" & userid & "' and request.userid = users.userid and request.requestid = requestdetail.requestid;") If ds.Tables(0).Rows.Count <> 0 Then gvrequestgrad.DataSource = ds.Tables(0) gvrequestgrad.DataBind() gvrequestgrad.SelectedIndex = -1 End If
-Unable to cast object of type 'System.Security.Principal.WindowsIdentity' to type 'System.Web.Security.FormsIdentity'. - Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. -Exception Details: System.InvalidCastException: Unable to cast object of type 'System.Security.Principal.WindowsIdentity' to type 'System.Web.Security.FormsIdentity'.
Dim ident As FormsIdentity = CType(User.Identity, FormsIdentity)
Dim ident As IPrincipal = CType(User.Identity, IPrincipal)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)