Hi,
I have a tricky thing to develop. We're needing to set a response header for "Content-Disposition: inline". After a few trial and errors I ended up placing the code in the last possible event
using System; using Dynamicweb.Extensibility.Notifications; namespace MyCustomWork.NotificationSubscribers { [Subscribe(Dynamicweb.Notifications.Standard.Page.AfterRender)] public class AfterRender : NotificationSubscriber { public override void OnNotify(string notification, NotificationArgs args) { if (!(args is Dynamicweb.Notifications.Standard.Page.AfterRenderArgs myArgs)) { return; } var isPdf = Convert.ToBoolean(Dynamicweb.Context.Current.Request.Params["pdf"]); if (isPdf) { Dynamicweb.Context.Current.Response.ClearHeaders(); Dynamicweb.Context.Current.Response.AddHeader("Content-Disposition", "inline;"); } } } }
This should work, but turns out that the notification is triggered too soon, because the HttpStreamHandler() is instantiated after the notification, basically creating multiple headers, which although Chrome and Edge are fine with. Firefox is not.
So this means I can't change Response Headers as required by this project.
Is there another way I could do this?
Best Regards,
Nuno Aguiar