Я использую System.Web.Optimization для объединения CSS и скрипта. Но теперь я хочу сделать CSS и скрипты встроенными, а не ссылаться на один файл.
Я пытаюсь создать метод расширениядля System.Web.Optimization.Render () , но я не могу предоставить параметр как HttpContextBase для метода GenerateBundleResponse ()
Ниже приведен мой код с ошибкой
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()));
}
}