简体   繁体   English

CreateUserWizard数据库访问Asp.Net

[英]CreateUserWizard Database Access Asp.Net

I added custom questions to the CreateUserWizard control and created an additional table in the ASPNETDB database called aspnet_UserInfo. 我向CreateUserWizard控件添加了自定义问题,并在ASPNETDB数据库中创建了一个名为aspnet_UserInfo的附加表。 How do I sql insert into table when the [Create User] button is clicked like they do for the username? 像单击用户名一样,如何单击[创建用户]按钮,如何将sql插入表中? Or do i just create the inserts separately on the button postback? 还是只在按钮回发中单独创建插入?

And also where is the sql statements that write the user name and password from the CreateUserWizard control? 还有从CreateUserWizard控件写入用户名和密码的sql语句在哪里?

There are a couple of events that occur while your creating a new user with the CreateUserWizard control (specifically the FinishButtonClick and the CreatedUser events). 使用CreateUserWizard控件创建新用户时,会发生一些事件(特别是FinishButtonClickCreatedUser事件)。 You could handle either one of those events and do your custom SQL insert into your aspnet_UserInfo table in the event handler. 您可以处理这些事件之一,然后将自定义SQL插入事件处理程序中的aspnet_UserInfo表中。

This MSDN tutorial is a great resource for customizing the CreateUserWizard process. 该MSDN教程是自定义CreateUserWizard流程的重要资源。

I don't know of a way to find out what specific SQL statements are executed when the library functions are called to create a new user. 我不知道一种方法来找出调用库函数来创建新用户时要执行哪些特定的SQL语句。 That doesn't mean there isn't a way though, I just don't know it =) 那并不意味着没有办法,我只是不知道=)

Addition ( based on comments ) : Considering your use-case, look in the code-behind for your "Register.aspx" file. 添加基于注释考虑到您的用例,请在后面的代码中查找“ Register.aspx”文件。 There is a line in there (by default) that looks like this: 其中(默认情况下)有一行如下所示:

FormsAuthentication.SetAuthCookie(RegisterUser.UserName, False)

Just delete that line and you'll be good - your Admin will continue to be logged in as himself after creating the new user. 只需删除该行,您会感觉很好-创建新用户后,您的管理员将继续以他本人的身份登录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM