diff --git a/.nuget/NuGet.Config b/.nuget/NuGet.Config deleted file mode 100644 index 67f8ea0..0000000 --- a/.nuget/NuGet.Config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.nuget/NuGet.exe b/.nuget/NuGet.exe deleted file mode 100644 index cb3ed03..0000000 Binary files a/.nuget/NuGet.exe and /dev/null differ diff --git a/.nuget/NuGet.targets b/.nuget/NuGet.targets deleted file mode 100644 index 46a1b6c..0000000 --- a/.nuget/NuGet.targets +++ /dev/null @@ -1,133 +0,0 @@ - - - - $(MSBuildProjectDirectory)\..\ - - - false - - - false - - - true - - - false - - - - - - - - - - - $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) - $([System.IO.Path]::Combine($(ProjectDir), "packages.config")) - - - - - $(SolutionDir).nuget - packages.config - - - - - $(NuGetToolsPath)\NuGet.exe - @(PackageSource) - - "$(NuGetExePath)" - mono --runtime=v4.0.30319 $(NuGetExePath) - - $(TargetDir.Trim('\\')) - - -RequireConsent - -NonInteractive - - - $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir "$(SolutionDir) " - $(NuGetCommand) pack "$(ProjectPath)" -Properties Configuration=$(Configuration) $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols - - - - RestorePackages; - $(BuildDependsOn); - - - - - $(BuildDependsOn); - BuildPackage; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Lib.Web.Mvc.sln b/Lib.Web.Mvc.sln index 14a3cb7..6b31ef6 100644 --- a/Lib.Web.Mvc.sln +++ b/Lib.Web.Mvc.sln @@ -1,13 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Express 2012 for Web -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{BF971E7D-E0D2-4DC3-81BF-7B0E941935DD}" - ProjectSection(SolutionItems) = preProject - .nuget\NuGet.Config = .nuget\NuGet.Config - .nuget\NuGet.exe = .nuget\NuGet.exe - .nuget\NuGet.targets = .nuget\NuGet.targets - EndProjectSection -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lib.Web.Mvc", "Lib.Web.Mvc\Lib.Web.Mvc.csproj", "{1332384E-DDEF-4B55-81E8-F6F0B0C779DC}" EndProject Global diff --git a/Lib.Web.Mvc/Html/PushPromiseExtensions.cs b/Lib.Web.Mvc/Html/PushPromiseExtensions.cs new file mode 100644 index 0000000..33f5c55 --- /dev/null +++ b/Lib.Web.Mvc/Html/PushPromiseExtensions.cs @@ -0,0 +1,76 @@ +using System; +using System.Web; +using System.Web.Mvc; + +namespace Lib.Web.Mvc.Html +{ + /// + /// Provides support for HTTP/2 Server Push during rendering. + /// + public static class PushPromiseExtensions + { + #region Constants + private const string _linkElement = "link"; + private const string _scriptElement = "script"; + + private const string _hrefAttribute = "href"; + private const string _relationAttribute = "rel"; + private const string _sourceAttribute = "src"; + private const string _typeAttribute = "type"; + #endregion + + #region Methods + /// + /// Provides HTTP/2 Server Push support for link elements. + /// + /// The HTML helper. + /// The virtual path of resource. + /// The relation (default is stylesheet). + /// + public static IHtmlString PushPromiseLink(this HtmlHelper htmlHelper, string contentPath, string relation = "stylesheet") + { + PushPromise(htmlHelper.ViewContext.HttpContext, contentPath); + + UrlHelper urlHelper = new UrlHelper(htmlHelper.ViewContext.RequestContext); + + TagBuilder linkTagBuilder = new TagBuilder(_linkElement); + linkTagBuilder.Attributes.Add(_relationAttribute, relation); + linkTagBuilder.Attributes.Add(_hrefAttribute, urlHelper.Content(contentPath)); + + return new HtmlString(linkTagBuilder.ToString()); + } + + /// + /// Provides HTTP/2 Server Push support for script elements. + /// + /// The HTML helper. + /// The virtual path of resource. + /// The type. + /// + public static IHtmlString PushPromiseScript(this HtmlHelper htmlHelper, string contentPath, string type = "") + { + PushPromise(htmlHelper.ViewContext.HttpContext, contentPath); + + UrlHelper urlHelper = new UrlHelper(htmlHelper.ViewContext.RequestContext); + + TagBuilder scriptTagBuilder = new TagBuilder(_scriptElement); + scriptTagBuilder.Attributes.Add(_sourceAttribute, urlHelper.Content(contentPath)); + + if (!String.IsNullOrWhiteSpace(type)) + { + scriptTagBuilder.Attributes.Add(_typeAttribute, type); + } + + return new HtmlString(scriptTagBuilder.ToString()); + } + + private static void PushPromise(HttpContextBase httpContext, string contentPath) + { + if (httpContext.Request.IsSecureConnection) + { + httpContext.Response.PushPromise(contentPath); + } + } + #endregion + } +} diff --git a/Lib.Web.Mvc/Lib.Web.Mvc.csproj b/Lib.Web.Mvc/Lib.Web.Mvc.csproj index a03e481..426e5fb 100644 --- a/Lib.Web.Mvc/Lib.Web.Mvc.csproj +++ b/Lib.Web.Mvc/Lib.Web.Mvc.csproj @@ -10,7 +10,7 @@ Properties Lib.Web.Mvc Lib.Web.Mvc - v4.0 + v4.6.1 512 ..\..\jqGrid Helper Examples\ @@ -50,6 +50,7 @@ + @@ -149,6 +150,8 @@ + + @@ -167,28 +170,28 @@ - - ..\..\..\Projekty\TPeczek.Blog.ContentSecurityPolicy\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.Helpers.dll + + ..\..\..\Projekty\Demo.AspNet.Mvc.Http2\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.Helpers.dll True - - ..\..\..\Projekty\TPeczek.Blog.ContentSecurityPolicy\packages\Microsoft.AspNet.Mvc.4.0.40804.0\lib\net40\System.Web.Mvc.dll + + ..\..\..\Projekty\Demo.AspNet.Mvc.Http2\packages\Microsoft.AspNet.Mvc.5.2.3\lib\net45\System.Web.Mvc.dll True - - ..\..\..\Projekty\TPeczek.Blog.ContentSecurityPolicy\packages\Microsoft.AspNet.Razor.2.0.20710.0\lib\net40\System.Web.Razor.dll + + ..\..\..\Projekty\Demo.AspNet.Mvc.Http2\packages\Microsoft.AspNet.Razor.3.2.3\lib\net45\System.Web.Razor.dll True - - ..\..\..\Projekty\TPeczek.Blog.ContentSecurityPolicy\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.dll + + ..\..\..\Projekty\Demo.AspNet.Mvc.Http2\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.dll True - - ..\..\..\Projekty\TPeczek.Blog.ContentSecurityPolicy\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Deployment.dll + + ..\..\..\Projekty\Demo.AspNet.Mvc.Http2\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Deployment.dll True - - ..\..\..\Projekty\TPeczek.Blog.ContentSecurityPolicy\packages\Microsoft.AspNet.WebPages.2.0.20710.0\lib\net40\System.Web.WebPages.Razor.dll + + ..\..\..\Projekty\Demo.AspNet.Mvc.Http2\packages\Microsoft.AspNet.WebPages.3.2.3\lib\net45\System.Web.WebPages.Razor.dll True @@ -197,7 +200,6 @@ -