NoTransform isn't working when trying to create new Bundle

本小妞迷上赌 提交于 2019-12-04 06:27:16
Hao Kung

The NoTransform class no longer needs to be public because starting in RC, a null Transform class on Bundle implicitly means NoTransform.

Before:

new Bundle("~/yourbundle", new NoTransform())

Now:

new Bundle("~/yourbundle")

We felt it was cleaner to not require a dummy instance. We kept it internal because it has a tiny bit of logic that would potentially cause some trouble, since the Transform is responsible for setting the contentType for the response. The default logic uses the file extension of the first file in your bundle (.js/.css).

Also with the addition of the Script/Styles Render helpers, you should no longer need to dynamically switch between different transforms based on debug=true|false. The helpers should take care of that for you.

Jon

not a direct answer to this but just to point it out to anyone who comes across this in the furture... it can be done via config as well, (see https://stackoverflow.com/a/12605451/6486)

<system.web>
    <compilation debug="true" />
    <!-- Lines removed for clarity. -->
</system.web>

This code is from MVC 4 Beta (or more precisely System.Web.Optimization beta1) but you are probably trying to compile it with MVC 4 RC (or more precisely System.Web.Optimization beta2) (if MVC 4 at all). In MVC 4 RC NoTransform is internal.

The NoTransform and other methods like Scripts, Styles.. are the new features of bundling and minification that is available in the MVC 4 beta and MVC 4 RC versions. I hope you are not using the proper version of ASP.NET MVC and hence you are getting the compilation errors.

http://blog.kurtschindler.net/post/disabling-bundling-and-minification-in-aspnet-45mvc-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!