This question is locked. New answers and comments are not allowed.
Please correct me if I am mistaken, but I understand that ScriptRegistrar (SR) handles merging by using the .render() call only once, usually in the master page. However, when using the razor view engine, render is never used so what is happening is that each call to SR outputs an identical set of files rather than merging them. This is obviously undesirable behavior as it wastes bandwidth and defeats the purpose of SR.
How can I get merging to work using the razor view engine?
Added to global.asax to change default location:
// set telerik default paths for scripts and styles
WebAssetDefaultSettings.ScriptFilesPath = "~/public/js/t";
WebAssetDefaultSettings.StyleSheetFilesPath = "~/public/css/t";
in web.config:
<!-- validation-->
<add name="v" combined="false" compress="false" enabled="true">
<items>
<add source="~/public/js/jquery.validate.min.js"/>
<add source="~/public/js/jquery.validate.unobtrusive.min.js"/>
</items>
</add>
I have this is my master page:
@( Html.Telerik().ScriptRegistrar())
and this in my view:
@(Html.Telerik().ScriptRegistrar()
.Scripts(s => s.AddSharedGroup("v")))
Then I run the view and view source. This is the result, a duplication rather than a merge
How can I get merging to work using the razor view engine?
Added to global.asax to change default location:
// set telerik default paths for scripts and styles
WebAssetDefaultSettings.ScriptFilesPath = "~/public/js/t";
WebAssetDefaultSettings.StyleSheetFilesPath = "~/public/css/t";
in web.config:
<!-- validation-->
<add name="v" combined="false" compress="false" enabled="true">
<items>
<add source="~/public/js/jquery.validate.min.js"/>
<add source="~/public/js/jquery.validate.unobtrusive.min.js"/>
</items>
</add>
I have this is my master page:
@( Html.Telerik().ScriptRegistrar())
and this in my view:
@(Html.Telerik().ScriptRegistrar()
.Scripts(s => s.AddSharedGroup("v")))
Then I run the view and view source. This is the result, a duplication rather than a merge
<script type="text/javascript" src="/public/js/t/2010.3.1318/jquery-1.4.4.min.js"></script> <script type="text/javascript" src="/public/js/jquery.validate.min.js"></script> <script type="text/javascript" src="/public/js/jquery.validate.unobtrusive.min.js"></script>
<!-- other content --> <script type="text/javascript" src="/public/js/t/2010.3.1318/jquery-1.4.4.min.js"></script> <script type="text/javascript" src="/public/js/jquery.validate.min.js"></script> <script type="text/javascript" src="/public/js/jquery.validate.unobtrusive.min.js"></script> </body>