I am trying to let a user fill in profile options when they are registering. I am using the providers that come with asp.net by default.
Example: User fills in this registration form:
Username
Email
Age <- This is what I have tried to add in.
Password
Confirm Password
I got the age to show up by doing the following.
1) Adding the following code to Web.config
<properties>
<add name="Word" type="String" />
<add name="Age" type="Int32" defaultValue="0" />
</properties>
2) Adding the following code to my register.aspx
view
<div class="editor-label">
<%: Html.LabelFor(m => Profile.Age) %>
</div>
<div class="editor-field">
<%: Html.TextBoxFor(m => Profile.Age)%>
<%: Html.ValidationMessageFor(m => Profile.Age)%>
</div>
I went to run it, I filled out the form and clicked register. I got this:
Timeout expired. The timeout period elapsed prior to 开发者_如何学编程completion of the operation or the server is not responding.
and
Line 127: _provider.CreateUser(userName, password, email, null, null, true, null, out status);
So that's what I have done, which is probably all wrong. What is the best way to do this?
I got something working by following this wiki I found.
http://wiki.asp.net/page.aspx/1327/profile-provider-in-aspnet-mvc/
It's not great and not super beginner friendly but better than anything else I found. I made the Profile model separate to the account model because it didn't explicitly state it at the start, but it still works alright.
Now I have a way to fill in the profile even if it's not at the same time as registering so I'll mark this as the correct answer.
精彩评论