简体   繁体   English

在ASP.NET MVC 2中使用Profile和CreateUserwizard

[英]Using Profile and CreateUserwizard in ASP.NET MVC 2

I am using this tutorial to create an application in ASP.NET MVC 2 where I can register users with custom profile properties using the CreateUserWizard control. 我正在使用本教程在ASP.NET MVC 2中创建应用程序,在其中可以使用CreateUserWizard控件使用自定义配置文件属性注册用户。

My problem is that the tutorial uses ASP.NET (not MVC) and it needs the code-behind of the control for handling the CreateUserWizard1_CreatedUser method. 我的问题是本教程使用ASP.NET(不是MVC),并且需要控件的代码来处理CreateUserWizard1_CreatedUser方法。

Since in ASP.NET MVC Views don't have a code-behind by default, I would like to know how can I have access to that method. 由于在ASP.NET中,MVC视图默认情况下没有代码隐藏,因此我想知道如何访问该方法。

Thanks in advance, Sam. 预先感谢,萨姆。

It looks like the CreateUserWizard is a standard ASP.Net control, and therefor is not going to work in MVC. 看起来CreateUserWizard是标准的ASP.Net控件,因此不能在MVC中使用。 You can reference standard ASP.Net controls from MVC views, but any functionality they have that relies on ViewState or PostBack is not going to work, since neither of those concepts exist in MVC. 您可以从MVC视图中引用标准ASP.Net控件,但是它们依赖于ViewState或PostBack的任何功能均无法使用,因为MVC中不存在这些概念。

That being said, it is possible to run ASP.Net WebForms and ASP.Net MVC within the same application, so if you wanted to create this functionality using webforms, you could do that, and simply link to the webforms page to do your user creation. 话虽这么说,有可能在同一应用程序中运行ASP.Net WebForms和ASP.Net MVC的,所以如果你想创建一个使用web表单此功能,你能做到这一点,并简单地链接到web表单页面做你的用户创建。

Have a look at this blog post from Scott Hanselman talking about running ASP.Net MVC, WebForms, and ASP.Net Dynamic Data in the same application. 看看Scott Hanselman的这篇博客文章 ,它讨论在同一应用程序中运行ASP.Net MVC,WebForms和ASP.Net动态数据。

You could also create a wizard-like ASP.NET MVC pattern, as described here: 您还可以创建类似于向导的ASP.NET MVC模式,如下所述:

http://www.highoncoding.com/Articles/647_Creating_Wizard_Using_ASP_NET_MVC_Part_1.aspx http://www.highoncoding.com/Articles/647_Creating_Wizard_Using_ASP_NET_MVC_Part_1.aspx http://www.highoncoding.com/Articles/647_Creating_Wizard_Using_ASP_NET_MVC_Part_1.aspx http://www.highoncoding.com/Articles/647_Creating_Wizard_Using_ASP_NET_MVC_Part_1.aspx

With MVC2, however, you will have a problem with partial model validation. 但是,使用MVC2,您将无法进行部分模型验证。 It can be solved by using a separate ViewModel for every page, or by using ActionFilters as described here: 可以通过为每个页面使用单独的ViewModel或按此处所述使用ActionFilters来解决此问题:

http://blog.stevensanderson.com/2010/02/19/partial-validation-in-aspnet-mvc-2/ http://blog.stevensanderson.com/2010/02/19/partial-validation-in-aspnet-mvc-2/

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

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