开发者

Asp/Razor CreateUser method

开发者 https://www.devze.com 2023-03-17 01:07 出处:网络
Okay, here\'s the issue in general. I am using System.Web.Security.SqlMembershipProvider for log in and registration for my website. And I am using Razor syntax (.cshtml files) for my view pages. One

Okay, here's the issue in general. I am using System.Web.Security.SqlMembershipProvider for log in and registration for my website. And I am using Razor syntax (.cshtml files) for my view pages. One of these pages is a "forgot password" page. In this page, I want to use some code that is only supported byWebMatrix.WebData.WebSecurity. I've added the necessary code to web.config and all that, so that's not my problem.

My problem is that now my Register code doesn't work. Specifically, the CreateUser method. What is hap开发者_开发百科pening is that, even though VisualStudio shows the CreateUser method as MembershipProvider.CreateUser, when the function is actually called (I've looked at the stack call, so I'm sure of this) is WebMatrix.WebData.SimpleMembershipProvider.CreateUser. This function is not supported by the system (according to the exception statement). Apparently, the CreateUser methods for both MembershipProvider and WebMatrix have the exact same signatures, so this appears to be the problem.

Here's the method code, for what it is worth, but, this code is created automatically, when I create the website in VisualStudio. And, by the way, I cannot change the parameters: _provider.CreateUser(userName, password, email, null, null, true, null, out status);

So, what is the solution? I would like to be able to explicitly specify the method in the code. Something like: _provider.MembershipProvider.CreateUser(userName, password, email, null, null, true, null, out status); Alas, I am not allowed to do this. So, is there a way to specify which function to call? Or maybe some other solution?


What happens when you use

Membership.CreateUser()

or

Membership.Provider.CreateUser()

Without seeing more of your code, its difficult to help.


Before you dig any further, you might want to check and see if the new ASP.NET Universal Providers by Microsoft work for you. They will most likely be the default providers for the next version of ASP.NET.

  • Introducing System.Web.Providers - ASP.NET Universal Providers for Session, Membership, Roles and User Profile on SQL Compact and SQL Azure - Scott Hanselman

  • ASP.NET Universal Providers - 0.1 - NuGet gallery

In your case, the equivalent provider would be System.Web.Providers.DefaultMembershipProvider

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号