Asp.net表单(VB.net)标识+;MySQL

Asp.net表单(VB.net)标识+;MySQL,mysql,asp.net,vb.net,forms,identity,Mysql,Asp.net,Vb.net,Forms,Identity,Asp.net窗体(VB.net)Identity+MySQL 嗨,我正在尝试编写一个基于本教程的代码。我想使用MySql和Identity。 辅导的: 目前,我的代码如下所示: Imports AspNet.Identity.MySQL Imports Microsoft.Owin.Security Imports Microsoft.AspNet.Identity Public Class ApplicationUser Inherits IdentityUser End Cl

Asp.net窗体(VB.net)Identity+MySQL

嗨,我正在尝试编写一个基于本教程的代码。我想使用MySql和Identity。 辅导的:

目前,我的代码如下所示:

Imports AspNet.Identity.MySQL
Imports Microsoft.Owin.Security
Imports Microsoft.AspNet.Identity

Public Class ApplicationUser
    Inherits IdentityUser

End Class

Public Class ApplicationDbContext
    Inherits MySQLDatabase

    Public Sub New(ByVal connectionName As String)
        MyBase.New(connectionName)
    End Sub

    Public Shared Function Create() As ApplicationDbContext
        Return New ApplicationDbContext("DefaultConnection")
    End Function
End Class


#Region "Helpers"
Public Class UserManager
    Inherits UserManager(Of ApplicationUser)
    Public Sub New()
           MyBase.New(New UserStore(Of ApplicationUser)(New ApplicationDbContext()))
    End Sub
End Class
Public Class IdentityHelper

    Public Const XsrfKey As String = "xsrfKey"

    Public Shared Sub SignIn(manager As UserManager, user As ApplicationUser, isPersistent As Boolean)
        Dim authenticationManager As IAuthenticationManager = HttpContext.Current.GetOwinContext().Authentication
        authenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie)
        Dim identity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie)
        authenticationManager.SignIn(New AuthenticationProperties() With {.IsPersistent = isPersistent}, identity)
    End Sub

    Public Const ProviderNameKey As String = "providerName"
    Public Shared Function GetProviderNameFromRequest(request As HttpRequest) As String
        Return request(ProviderNameKey)
    End Function

    Private Shared Function IsLocalUrl(url As String) As Boolean
        Return Not String.IsNullOrEmpty(url) AndAlso ((url(0) = "/"c AndAlso (url.Length = 1 OrElse (url(1) <> "/"c AndAlso url(1) <> "\"c))) OrElse (url.Length > 1 AndAlso url(0) = "~"c AndAlso url(1) = "/"c))
    End Function

    Public Shared Sub RedirectToReturnUrl(returnUrl As String, response As HttpResponse)
        If Not [String].IsNullOrEmpty(returnUrl) AndAlso IsLocalUrl(returnUrl) Then
            response.Redirect(returnUrl)
        Else
            response.Redirect("~/")
        End If
    End Sub
End Class
#End Region
导入AspNet.Identity.MySQL
导入Microsoft.Owin.Security
导入Microsoft.AspNet.Identity
公共类应用程序用户
继承身份者
末级
公共类ApplicationDbContext
继承MySQLDatabase
Public Sub New(ByVal connectionName作为字符串)
MyBase.New(connectionName)
端接头
公共共享函数Create()作为ApplicationDbContext
返回新的ApplicationDbContext(“DefaultConnection”)
端函数
末级
#地区“助手”
公共类用户管理器
继承(ApplicationUser的)用户管理器
公共分新()
New(ApplicationUser的新用户存储)(新ApplicationDbContext())
端接头
末级
公共类标识帮助器
Public Const XsrfKey As String=“XsrfKey”
公共共享子签名(管理器作为用户管理器,用户作为应用程序用户,iPersistent作为布尔值)
Dim authenticationManager作为IAAuthenticationManager=HttpContext.Current.GetOwinContext().Authentication
authenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie)
Dim identity=manager.CreateIdentity(用户,默认身份验证类型.ApplicationOkie)
authenticationManager.SignIn(带有{.IsPersistent=IsPersistent},标识的新AuthenticationProperties())
端接头
Public Const ProviderNameKey为String=“providerName”
公共共享函数GetProviderNameFromRequest(请求为HttpRequest)作为字符串
返回请求(ProviderNameKey)
端函数
私有共享函数IsLocalUrl(url为字符串)为布尔值
返回Not String.IsNullOrEmpty(url)AndAlso((url(0)=“/”c AndAlso(url.Length=1 OrElse(url(1)”/“c AndAlso url(1)”\“c)))OrElse(url.Length>1 AndAlso url(0)=“~”c AndAlso url(1)=“/”c))
端函数
公共共享子重定向返回URL(返回URL为字符串,响应为HttpResponse)
如果不是[String].IsNullOrEmpty(returnUrl)和IsLocalUrl(returnUrl),则
response.Redirect(返回URL)
其他的
响应。重定向(“~/”)
如果结束
端接头
末级
#末端区域
但存在一个错误(或多个错误)

MyBase.New(ApplicationUser的新用户存储)(新ApplicationDbContext())

我不知道C#,在本教程中很难继续:

如何在VB中实现这一点


非常感谢。

尝试将其更改为以下内容:

MyBase.New(New UserStore(Of ApplicationUser)(TryCast(context.[Get](Of ApplicationDbContext)(), MySQLDatabase)))

谢谢你,但还没有。