How to push CSS file though Http2?

464 Views Asked by At

I'm implementing Asp.net framework 4.6.1 project and I want to add HTTP2 server push for that project. Here I'm working with aspx.cs file and I used Html extension to push style-sheets as follows:

<%: Html.PushPromiseStylesheet("~/content/styles/Tree.common.min.css") %>

But this is not work for me. Is there is any other way to push css file via HTTP2 server push?

1

There are 1 best solutions below

0
Hansika Wanniarachchi On

PUSH_PROMISE method can be used to apply HTTP/2 server push because the server creates the PUSH_PROMISE frame to the response part of a normal browser- initiated stream. Response objects with the context of a request which has a HTTP connection is used to server push. In a server side under the HTTP connection method like Page_load method can be used to apply Response.PUSHPROMISE for push all the relevant scripts, styles and images without the client having to request each one explicitly.

 Response.PushPromise("direction/to/style-sheet");