asp.net mvc 3 - MVC3 Profile setting Property Not Found -


enter code herei have read few other posts mine, still no answers available.

i have editorfor profile information, , gets data fine selected user, once try , save it, following error.

the settings property 'firstname' not found.

the thing post, operation im not doing yet. think trying load, or profile object fill model once posted. theres nothing in callstack can see find happening.

web.config:

 <profile inherits="myweb.businesslayer.models.account.profile" enabled="true" defaultprovider="aspnetsqlprofileprovider">   <providers>     <clear/>     <add name="aspnetsqlprofileprovider" type="system.web.profile.sqlprofileprovider" connectionstringname="applicationservices" applicationname="my website"/>   </providers> </profile> 

profile class

public class profile : profilebase {     [display(name = "first name")]     [required(errormessageresourcename = "err_req_field", errormessageresourcetype = typeof(resources))]     [stringlength(50, minimumlength = 3, errormessageresourcename = "err_len_field", errormessageresourcetype = typeof(resources))]     public virtual string firstname     {                 {             return (this.getpropertyvalue("firstname").tostring());         }         set         {             this.setpropertyvalue("firstname", value);         }     } ... abreviated 

controller actions

    public viewresult editprofile(guid id)     {         var user = _userservice.get(id);          profile _profile = profile.getprofile(user.username);          return view(_profile);     }      [acceptverbs(httpverbs.post)]     public redirecttorouteresult editprofile(profile profile)     {         return redirecttoaction("index" , "useradministration" );     } 

the display editor works fine, data, when try post, this. other ideas? other idea, might ajax post, paramerts split out rather profile model, read , set./.. thoughts?

after post form profile class model binder tries bind model wants properties ('firstname' among others).

the problem model form not complete (and can't be) profile acting not authorized , not known.

you can see when set breakpoint before getter firstname property. after breakpoint hits, locals window , locate 'this'. expand 'base' property , see isanonymous property set true.

the binder cannot recognize profile after comes post form. solution code this:

[acceptverbs(httpverbs.post)] public redirecttorouteresult editprofile(profilemodel profilemodel) {     // current user profile     profile profile = profile.getuserprofile();     profile.firstname = profilemodel.firstname;      // save profile     profile.save();      return redirecttoaction("index" , "useradministration" ); } 

so create user profile based on current logged user , update properties.


Comments