मुझे लगता है कि .NET के लिए वाईयूआई कंप्रेसर आपको वही करेगा जो आपको चाहिए।
http://yuicompressor.codeplex.com/
संपादित: के रूप में मैं प्रश्न पढ़ने में भूलना ऊपर गलत है। नीचे दिया गया कोड एक प्रतिक्रिया फ़िल्टर स्थापित करेगा जो आपको आउटपुट में हेरफेर करने की इजाजत देता है, इस मामले में यह केवल न्यूलाइन अक्षरों को हटा देता है।
उम्मीद है कि इससे मदद मिलती है।
[HandleError]
public class HomeController : Controller
{
[Minify]
public ActionResult Index()
{
ViewData["Message"] = "Welcome to ASP.NET MVC!";
return View();
}
}
public class Minify : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
//You can check if the content type is CSS/JS here and prevent the filter running on HTML pages
filterContext.HttpContext.Response.Filter = new MinifyFilter(filterContext.HttpContext.Response.Filter);
base.OnActionExecuting(filterContext);
}
}
public class MinifyFilter : MemoryStream
{
private StringBuilder outputString = new StringBuilder();
private Stream outputStream = null;
public MinifyFilter(Stream outputStream)
{
this.outputStream = outputStream;
}
public override void Write(byte[] buffer, int offset, int count)
{
outputString.Append(Encoding.UTF8.GetString(buffer));
}
public override void Close()
{
//Call the minifier here, your data is in outputString
string result = outputString.ToString().Replace(Environment.NewLine, string.Empty);
byte[] rawResult = Encoding.UTF8.GetBytes(result);
outputStream.Write(rawResult, 0, rawResult.Length);
base.Close();
outputStream.Close();
}
}
क्या आपने प्रकाशित होने पर minify माना है? आप एमएस बिल्ड का उपयोग करके ऐसा कर सकते हैं, यह वह है जिसे हम http://code.google.com/p/antix-software/wiki/MSBuild –
उपयोग करते हैं, यह कोई नहीं है कि ये परिणाम वास्तव में स्पार्क दृश्य हैं जो एम्बेडेड के साथ जावास्क्रिप्ट हैं सी # (स्थानीयकरण, डिफ़ॉल्ट मान आदि)। इसलिए उन्हें गतिशील रूप से निष्पादित करने की आवश्यकता है और पूर्व-निर्धारित नहीं किया जा सकता है। इसे पोस्ट निष्पादित करने की आवश्यकता है। –