I am using System.Web.Optimization to bundle the css and script.But now I want to render css and scripts inline instead of refer to a single file.
I am trying to create an extension method for System.Web.Optimization.Render() but I am not able to provide parameter as HttpContextBase for the method GenerateBundleResponse()
Following is my code with Error
public static class OptimizationStylesExtention
{
private static string GetBundleContent(HttpContextBase httpContextBase,
string bundleVirtualPath)
{
return BundleTable.Bundles
.Single(b => b.Path == bundleVirtualPath)
.GenerateBundleResponse(new BundleContext(httpContextBase,
BundleTable.Bundles, bundleVirtualPath)).Content;
}
public static IHtmlString RenderInline(this HtmlString str, params string[]
bundleVirtualPath)
{
StringBuilder bundleContent = new StringBuilder();
foreach (var virtualPath in bundleVirtualPath)
{
bundleContent.Append(BundleTable.Bundles.Single(b => b.Path == virtualPath)
.GenerateBundleResponse(new BundleContext(str, BundleTable.Bundles, virtualPath)));
}
return new HtmlString(string.Format("{<style>{0}</style>}", bundleContent.ToString()));
}
}