468,145 Members | 1,371 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,145 developers. It's quick & easy.

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.HttpContext'.

This is my code:

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

Expand|Select|Wrap|Line Numbers
  1. Context.GetOwinContext
Error: Not a member of httpContext

Expand|Select|Wrap|Line Numbers
  1. 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:

Expand|Select|Wrap|Line Numbers
  1. Imports Microsoft.AspNet.Identity
  2. Imports Microsoft.AspNet.Identity.EntityFramework
  3. Imports Microsoft.AspNet.Identity.Owin
  4. Imports Owin
Where do I go from here, please?

Thanks!
Jan 19 '19 #1
1 6118
SioSio
238 128KB
Are you writing like this?
Dim Context As HttpContext

If so, it will look like
Context.Current.GetOwinContext
Dec 19 '19 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by | last post: by
2 posts views Thread by cameron | last post: by
4 posts views Thread by John Mick | last post: by
4 posts views Thread by rohinichandrap | last post: by
3 posts views Thread by =?Utf-8?B?UGhpbCBKb2huc29u?= | last post: by
30 posts views Thread by didacticone | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.