Copied to clipboard

Flag this post as spam?

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


  • Umbraco Newbie 22 posts 124 karma points
    Apr 27, 2017 @ 20:34
    Umbraco Newbie
    0

    Modules in C# need to get value from Umbraco

    Hi I need to get a value from Umbraco in a module, but no matter what I try I cannot get it to work as cannot get the value, can anyone help please.

    My code is below:

    public class TestModule : IHttpModule
        {
            public void Dispose()
            {
                //do nothing
            }
    
            public void Init(HttpApplication app)
            {
                app.BeginRequest += (app_BeginRequest);
    
            }
    
            private void app_BeginRequest(object sender, EventArgs e)
            {
                UmbracoHelper helper = new UmbracoHelper(UmbracoContext.Current);
                var helper2 = UmbracoContext.Current.ContentCache;
    
                var test3 = helper.UmbracoContext.PageId;
    
                IPublishedContent content = helper.TypedContent(test3);
    
                var propertyValue = content.GetPropertyValue("valueRequired");
            }
        }
    

    The value can be on any Umbraco page/doctype

  • Marcio Goularte 388 posts 1360 karma points
    Apr 27, 2017 @ 21:02
  • Umbraco Newbie 22 posts 124 karma points
    Apr 27, 2017 @ 21:20
    Umbraco Newbie
    0

    Hi Marcio Goularte

    Think I came across that post before, looked at so many so not sure. I get message 'UmbracoContext.EnsureContext' is obsolete.

    Is it possible for another example

  • Marcio Goularte 388 posts 1360 karma points
    Apr 27, 2017 @ 22:42
  • Damiaan 442 posts 1302 karma points MVP 6x c-trib
    Apr 28, 2017 @ 08:24
    Damiaan
    1

    It's not because something that is marked obsolete, that it is not working. A few methods have been deprecated because there will be (a better / easier) alternative in v8. However v8 is not launched yet. So for many calls you do not need to panic.

    If the "obsoleted" method is not mentioning what you SHOULD use, then don't change it yet.

Please Sign in or register to post replies

Write your reply to:

Draft