Custom Block List Property
j

johnkhigginson

about 1 year ago
I have a custom blocklist property as part of a document type. It's very simple and only accepts one block component type. I am trying to access this property in my code. While following the umbraco documentation here: https://docs.umbraco.com/umbraco-cms/fundamentals/backoffice/property-editors/built-in-umbraco-property-editors/block-editor/block-list-editor, It tells me it returns an IEnumerable. On that same page, it says that I can pull the value as that or BlockListModel... but with either, it returns null.
if (content.HasProperty("locations"))
{
    var locations = content.GetValue<BlockListModel>("locations");
    (or)
    var locations = content.GetValue<IEnumerable<BlockListItem>>("locations");
    ...
}
If I pull the value as a string or dynamic object, it will show as:
{"layout":{"Umbraco.BlockList":[{"contentUdi":"umb://element/74437d1928534a9287430056e140b99b"},{"contentUdi":"umb://element/382ddba6783948b28696798b3b6dad16"}]},"contentData":[{"contentTypeKey":"0285ad7f-763f-4bc5-80be-45f85f8a39e6","udi":"umb://element/74437d1928534a9287430056e140b99b","city":"Colville","stateA":"[\"WA\"]","name":"Colville Toyota"},{"contentTypeKey":"0285ad7f-763f-4bc5-80be-45f85f8a39e6","udi":"umb://element/382ddba6783948b28696798b3b6dad16","stateA":"[\"OR\"]","name":"Coos Bay Toyota","city":"Coos Bay"}],"settingsData":[]}
In converting to the BlockListModel, it has to be erroring causing it to return null; right? I need to pull the values this way because I am using those values to calculate other properties and then save that property to the document. Anyone running into this or have a solution? Is this enough info? I feel like I've tried quite a bit without success.
Issues with handling Save and Publish events in Umbraco - Need Help!
b

baristaner

11 months ago
Hello everyone, I am encountering some challenges with handling Save and Publish events in Umbraco, specifically using SaveAndPublishHandler class. Here are the details of my issue: **Problem Description**: I have implemented a SaveAndPublishHandler class in Umbraco to handle Saved and Published events for content items. The goal is to send an HTTP POST request to an external endpoint whenever content is saved or published with a specific ParentId (in my case, ParentId 1249). *Code : *
c#
        public SaveAndPublishHandler(IContentService contentService)
        {
            _contentService = contentService;
        }

        public void Initialize()
        {
            ContentService.Saved += ContentService_Saved;
        }

        public void Terminate()
        {
            ContentService.Saved -= ContentService_Saved;
        }

        private void ContentService_Saved(IContentService sender, SaveEventArgs<IContent> e)
        {
            foreach (var content in e.SavedEntities)
            {
                if (content.ParentId == 1249)
                {
                    var dataToSend = new { ContentId = content.Id, Title = content.Name };
                    var json = Newtonsoft.Json.JsonConvert.SerializeObject(dataToSend);
                    var contentToSend = new StringContent(json, Encoding.UTF8, "application/json");

                    using (var httpClient = new HttpClient())
                    {
                        var endpointUrl = "http://localhost:65137/umbraco/surface/UpdateApprovedAccount/UpdateApprovedAccountV2"; 

                        var response = httpClient.PostAsync(endpointUrl, contentToSend).Result;

                        var responseContent = response.Content.ReadAsStringAsync().Result;
                    }
                }
            }
        }
Composing :
c#
public void Compose(Composition composition) {
composition.Components().Append<SaveAndPublishHandler>();
}
Why does backoffice log out after ~1 minute?
t

TackleMcClean 🏅

11 months ago
We have suffered from this issue before when setting up a new project on Azure. Old thread: https://discord.com/channels/869656431308189746/1183873525031911554 Now, we are seeing this issue on local development on localhost:8080 on a project where we're upgrading from Umbraco 10 to 13. After logging into the CMS, there is about a 40-60 second wait. Then there is a call to
/umbraco/backoffice/umbracoapi/authentication/GetRemainingTimeoutSeconds
that returns:
)]}',
0.0
Upon which the user is logged out showing message "Session timed out." We have tried using incognito mode to rule out cookies, as well as completely fresh browser profile in Chrome. Are we missing something completely basic for this problem to occur? appsetting Umbraco.CMS.Global.TimeOut is set to
08:00:00
. 8 hours is more than 1 minute. We have not supplied any other setting that should affect this. In our previous 'fresh' project the settings were also default. Umbraco.CMS.Security.KeepUserLoggedIn is not set to
true
thus it should be interpreted as the default
false
. > When set to false a user will be logged out after a specific amount of time has passed with no activity. You can specify this time span in the global settings with the TimeOut key. This is exactly what we've done. Umbraco.CMS.Security.AllowConcurrentLogins is showing a bit of a strange behavior. We don't have this defined at all. But setting it to true, and then restarting Umbraco, and then simply reloading the browser window of the recently auto-logged out user in a fresh browser profile will automatically log them in and show the backoffice. Logging out above mentioned user and then logging in seems to work fine as well.
GetRemainingTimeoutSeconds
returns the full 8 hours. However, logging out, setting
AllowConcurrentLogins
to false again and then logging back in, the problem reappears. In our tests, this is the only browser window using the site. Why are we seeing this problem?