Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Filip Lundby 128 posts 149 karma points
    Jun 27, 2014 @ 11:14
    Filip Lundby
    0

    Get and set member properties through razor

    Is it be possible to get and set Umbraco Member profile properties through razor script?

    In the Umbraco Member section, under Member Types, I've added my property to the member type "Member".

    What I've tried:

    @using System.Web.Security;
    @using System.Web.Profile;
    ...
    var profile = ProfileBase.Create(username);
    profile.SetPropertyValue("FirstName", "John"); // This is line 32 - error occures here.
    profile.Save();

     

    This error is throw in frontend:

    Error Loading Razor Script (file: Create Account) The settings property 'FirstName' was not found.    at System.Configuration.SettingsBase.SetPropertyValueByName(String propertyName, Object propertyValue)
      at System.Configuration.SettingsBase.set_Item(String propertyName, Object value)
      at System.Web.Profile.ProfileBase.SetInternal(String propertyName, Object value)
      at System.Web.Profile.ProfileBase.set_Item(String propertyName, Object value)
      at ASP._Page_macroScripts_CreateAccount_cshtml.Execute() in c:\project1\MacroScripts\CreateAccount.cshtml:line 32
      at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
      at System.Web.WebPages.WebPage.ExecutePageHierarchy()
      at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
      at umbraco.MacroEngines.RazorMacroEngine.ExecuteRazor(MacroModel macro, INode currentPage)
      at umbraco.MacroEngines.RazorMacroEngine.Execute(MacroModel macro, INode currentPage)
    

     

  • Charles Afford 1163 posts 1709 karma points
    Jun 29, 2014 @ 16:13
    Charles Afford
    0

    This is a bit old but will point you in the right direction :)

    http://charlesafford.com/blog-folder/umbraco-members-and-aspnet-membership-provider-1-1/

Please Sign in or register to post replies

Write your reply to:

Draft