Setup for asynchronously page processing

Posted by Community Admin on 03-Aug-2018 07:22

Setup for asynchronously page processing

All Replies

Posted by Community Admin on 10-May-2012 00:00

I need to set async="true" for the page, because my logic actively uses SyncronizationContext pattern. How to make it in sitefinity?

Posted by Community Admin on 13-May-2012 00:00

I don't believe that nobody uses that asp.net feature, please help me, I really need it.

Posted by Community Admin on 14-May-2012 00:00

Hello Yury,

To set the async property of a Sitefinity page you will have to inherit the SitefinityPageResolver and override the SetPageDirectives method.

Here are the steps you need to follow:

  1. Implement your custom page resolver inherited from SitefinityPageResolver:
  2. public class CustomPageResolver : SitefinityPageResolver
        
            protected override void SetPageDirectives(PageData pageData, DirectiveCollection directives)
            
                var pageAttribs = new NameValueCollection(StringComparer.OrdinalIgnoreCase);
                pageAttribs["Language"] = "C#";
                this.AddPageDirectiveValue(pageAttribs, "EnableViewState", pageData.EnableViewState, true);
                this.AddPageDirectiveValue(pageAttribs, "EnableViewStateMac", pageData.EnableViewStateMac, true);
                this.AddPageDirectiveValue(pageAttribs, "ViewStateEncryptionMode", pageData.ViewStateEncryption, ViewStateEncryptionMode.Auto);
                this.AddPageDirectiveValue(pageAttribs, "MaintainScrollPositionOnPostback", pageData.MaintainScrollPositionOnPostback, false);
                this.AddPageDirectiveValue(pageAttribs, "Trace", pageData.Trace, false);
                this.AddPageDirectiveValue(pageAttribs, "TraceMode", pageData.TraceMode, TraceMode.SortByTime);
                this.AddPageDirectiveValue(pageAttribs, "ErrorPage", pageData.ErrorPage);
                this.AddPageDirectiveValue(pageAttribs, "EnableTheming", pageData.EnableTheming, true);
                this.AddPageDirectiveValue(pageAttribs, "EnableEventValidation", pageData.EnableEventValidation, true);
                this.AddPageDirectiveValue(pageAttribs, "EnableSessionState", pageData.EnableSessionState, true);
                this.AddPageDirectiveValue(pageAttribs, "ResponseEncoding", pageData.ResponseEncoding);
                this.AddPageDirectiveValue(pageAttribs, "ValidateRequest", pageData.ValidateRequest, true);
                this.AddPageDirectiveValue(pageAttribs, "Title", pageData.HtmlTitle);
                this.AddPageDirectiveValue(pageAttribs, "MasterPageFile", pageData.MasterPage);
                this.AddPageDirectiveValue(pageAttribs, "MetaDescription", pageData.Description);
                this.AddPageDirectiveValue(pageAttribs, "MetaKeywords", pageData.Keywords);
                this.AddPageDirectiveValue(pageAttribs, "Buffer", pageData.BufferOutput, true);
                this.AddPageDirectiveValue(pageAttribs, "Inherits", pageData.CodeBehindType);
                this.AddPageDirectiveValue(pageAttribs, "Async", "true");
     
                directives.Add(new Directive("Page", pageAttribs));
            
        
  3. The marked line in the code above should set the Async directive of the page to true.
  4. The new page resolver should be registered in the Object Factory. This should be done after the Sitefinity Bootstrapper initialization. On application start, you need to subscribe for the "Initilized" event using the following code:
    protected void Application_Start(object sender, EventArgs e)
           
               Bootstrapper.Initialized += OnInitialized;
                
           
     
           private static void OnInitialized(object sender, ExecutedEventArgs args)
           
               if (!ObjectFactory.Container.IsRegistered<CustomPageResolver>("CustomPageResolver"))
               
                   ObjectFactory.Container.RegisterType<IVirtualFileResolver, CustomPageResolver>("CustomPageResolver",
                      new ContainerControlledLifetimeManager(), new InjectionConstructor());
               
           
  5. In Advanced settings define the resolver to be used in your application: Advanced Settings > VirtualPathSettings > Virtual Paths > Create New VirtualPath = "~/SFPageService/*", ResourceLocation = "", ResolverName ="CustomPageResolver"

Using the pageData parameter you may set the async directive only to specific pages.

All the best,
Lilia Messechkova
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 14-May-2012 00:00

Thank you, I really appreciate you help. 

This thread is closed