Setup for asynchronously page processing
I need to set async="true" for the page, because my logic actively uses SyncronizationContext pattern. How to make it in sitefinity?
I don't believe that nobody uses that asp.net feature, please help me, I really need it.
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:
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));
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());
Thank you, I really appreciate you help.