Errors in Visual Studio register.aspx file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bluenose
    New Member
    • Apr 2012
    • 56

    Errors in Visual Studio register.aspx file

    Hello

    I am getting the following compilation error in my register.aspx file:

    C30456: 'GetOwinContext ' is not a member of 'System.Web.Htt pContext'.

    This is my code:

    Code:
     Protected Sub CreateUser_Click(sender As Object, e As EventArgs)
            Dim userName As String = Email.Text
            Dim manager = Context.GetOwinContext().GetUserManager(Of ApplicationUserManager)()
            Dim signInManager = Context.GetOwinContext().Get(Of ApplicationSignInManager)()
            Dim user = New ApplicationUser() With {.userName = userName, .Email = userName}
            Dim result = manager.Create(user, Password.Text)
            If result.Succeeded Then
                ' For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                ' Dim code = manager.GenerateEmailConfirmationToken(user.Id)
                ' Dim callbackUrl = IdentityHelper.GetUserConfirmationRedirectUrl(code, user.Id, Request)
                ' manager.SendEmail(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=""" & callbackUrl & """>here</a>.")
    
                signInManager.SignIn(user, isPersistent:=False, rememberBrowser:=False)
                IdentityHelper.RedirectToReturnUrl(Request.QueryString("ReturnUrl"), Response)
            Else
                ErrorMessage.Text = result.Errors.FirstOrDefault()
            End If
        End Sub
    The following, from the above code, are underlined in red:

    Code:
    Context.GetOwinContext
    Error: Not a member of httpContext

    Code:
    IdentityHelper
    Error: it is not declared.

    At the top of my file, the following are underlined in VS 2017 in green as not being necessary:

    Code:
    Imports Microsoft.AspNet.Identity
    Imports Microsoft.AspNet.Identity.EntityFramework
    Imports Microsoft.AspNet.Identity.Owin
    Imports Owin
    Where do I go from here, please?

    Thanks!
  • SioSio
    Contributor
    • Dec 2019
    • 272

    #2
    Are you writing like this?
    Dim Context As HttpContext

    If so, it will look like
    Context.Current .GetOwinContext

    Comment

    Working...