Copied to clipboard

Flag this post as spam?

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


  • Jason 2 posts 32 karma points
    Jun 20, 2015 @ 06:35
    Jason
    0

    Async="true"

    I have a problem I am hoping someone may be able to help with. I have a page that is dependent on various external sources. To avoid a slow page load time, I am trying to load the information from the external sources asynchronously. Very simply, I have the following:

    Private Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    
        Page.RegisterAsyncTask(New PageAsyncTask(AddressOf LoadInfo))
    
    End Sub
    
    Private Async Function LoadInfo() As Task
    
        Await Task.Run(Sub()
                          ' Blah blah blah
                       End Sub)
    End Function
    

    Outside of Umbraco, this works perfectly however, when I run this within Umbraco, I get the following:

    Additional information: This operation requires the page to be asynchronous (the Async attribute must be set to true).

    I am new to Umbraco but I can't see anywhere within the CMS to alter the page parameters. From what I can see, pages inherit from Masterpages which don't have the Async parameter...

    In short, am I able to somehow set the Async'"true" page parameter somewhere?

    Any pointers greatly appreciated.

  • Peter Gregory 408 posts 1614 karma points MVP 3x admin c-trib
    Jun 22, 2015 @ 01:52
    Peter Gregory
    101

    Hey Jason

    I ran into this issue a few years back when I was working in Web Forms. TBH I cant fully remember how I resolved.

    The MasterPage that Umbraco Templates inherit from can be found in

    /umbraco/masterpages/default.Master

    However you can't add Async="true" on a master it needs to be set at the page level.

    Try add it to the declaration on that default.aspx page in the root as this is the page that Umbraco loads for every request. Be aware though that you are essentially modifying the core although only in a minor way but just make sure that if you upgrade in the future you remember you did this.

  • Jason 2 posts 32 karma points
    Jun 22, 2015 @ 09:22
    Jason
    0

    So simple! Just what I was after - thanks Peter.

Please Sign in or register to post replies

Write your reply to:

Draft