Anton Maiorov Anton Maiorov - 1 year ago 148
ASP.NET (C#) Question

Bundler Transformer Autoprefixer postprocess file knowing psysical path

I have a project in ASP.NET MVC and I want to use Bundler Transformer Autoprefixer to process my css files.
My use case is a little bit unusual and I need to process css content from physical path like


I think I can use AutoprefixCssPostProcessor class to do so, but it allows to process assets, that require virtual path to the file.
Is it possible to postprocess such file using AutoprefixCssPostProcessor?

Answer Source


    var tempFileVirtualPath = $"/App_Data/Temp/{Guid.NewGuid()}.css"        
    System.IO.File.WriteAllText(Server.MapPath(tempFileVirtualPath), initialCssContent);
    var autoprefixer = new AutoprefixCssPostProcessor();
    var content = autoprefixer.PostProcess(new Asset(tempFileVirtualPath)).Content;
    var absolutePath = "C:\somewhere\style.css";
    System.IO.File.WriteAllText(absolutePath, content);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download