自定义会员资格提供程序 - 我的自定义 CreateUser 函数中使用不同参数时出错

发布于 2024-11-02 07:10:26 字数 1549 浏览 3 评论 0原文

我想使用自定义成员资格提供程序创建新用户,但我不想使用创建的默认函数。

我不想使用这个

Public Overrides Function CreateUser(ByVal username As String,
                                         ByVal password As String,
                                         ByVal email As String,
                                         ByVal passwordQuestion As String,
                                         ByVal passwordAnswer As String,
                                         ByVal isApproved As Boolean,
                                         ByVal providerUserKey As Object,
                                         ByRef status As System.Web.Security.MembershipCreateStatus) As System.Web.Security.MembershipUser
        Return Nothing
  End Function

而是我想使用这个

Public Overloads Function CreateUser(ByVal username As String,
                                         ByVal email As String,
                                         ByVal number As String,
                                         ByVal isApproved As Boolean,
                                          ByRef status As System.Web.Security.MembershipCreateStatus) As System.Web.Security.MembershipUser

所以当我使用第二个选项时我得到这个波浪线说“引用非共享成员需要对象引用

我引用了 . dll 像这样正确

Imports CustomProviders

但是当我尝试创建一个用户(如下图所示)时它不起作用。我正在做一些明显错误的事情。我不知道那是什么。

在此处输入图像描述

已解决: 我发现波浪线是由于铸造问题造成的。我正在引用类库成员,而没有在我的网页代码后面的方法中进行转换。我认为另一个也得到了照顾。

I want to Create a new User using Custom Membership Provider but I don't want to use the default function that is created.

I don't want to use this

Public Overrides Function CreateUser(ByVal username As String,
                                         ByVal password As String,
                                         ByVal email As String,
                                         ByVal passwordQuestion As String,
                                         ByVal passwordAnswer As String,
                                         ByVal isApproved As Boolean,
                                         ByVal providerUserKey As Object,
                                         ByRef status As System.Web.Security.MembershipCreateStatus) As System.Web.Security.MembershipUser
        Return Nothing
  End Function

Instead I want to use this

Public Overloads Function CreateUser(ByVal username As String,
                                         ByVal email As String,
                                         ByVal number As String,
                                         ByVal isApproved As Boolean,
                                          ByRef status As System.Web.Security.MembershipCreateStatus) As System.Web.Security.MembershipUser

So when I use second option I get this squiggly lines saying "Reference to a non-shared member requires an object reference"

I referenced the .dll correctly like this

Imports CustomProviders

But when I try to create a user as shown in this below image it doesn't work. I am doing something clearly wrong. I don't know what it is.

enter image description here

Resolved:
I found that the squiggly line was due to casting problem. I was referencing the class library member without casting in my web page code behind method. I think the other is also taken care off.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

來不及說愛妳 2024-11-09 07:10:26

嘿,你的代码可以工作(对我来说编译没问题)我刚刚创建了一个新的会员提供程序并使用了你的 createuser 方法。工作正常。

如果您只是想发送更少的参数,为什么不使用可选参数功能,以便调用者仍然可以调用具有有限参数的方法。这样你就会自动摆脱你的问题(我不确定这是什么:)?)

http://msdn.microsoft.com/en-us/library/f25e2b6b(v=VS.100).aspx

Hey, your code works (compiles okay with me) I just created a new membership provider and used your createuser method. It works Okay.

If you just want to send less parameters, why dont you use optional parameter feature so that your caller's can still call the method with limited parameters. This way you will automatically get out of your problem (which I am not sure what is :) ?)

http://msdn.microsoft.com/en-us/library/f25e2b6b(v=VS.100).aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文