Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从C#MVC4中的插件更改资源(JS&CSS)URL_C#_Asp.net_Asp.net Mvc 3_Asp.net Mvc 4_Nopcommerce - Fatal编程技术网

如何从C#MVC4中的插件更改资源(JS&CSS)URL

如何从C#MVC4中的插件更改资源(JS&CSS)URL,c#,asp.net,asp.net-mvc-3,asp.net-mvc-4,nopcommerce,C#,Asp.net,Asp.net Mvc 3,Asp.net Mvc 4,Nopcommerce,我正在研究nopCommerce,并注意到脚本和css以以下方式包含在Root_Head.cshtml文件中 Html.AppendCssFileParts("~/Content/smoothness/jquery-ui-1.8.17.custom.css"); Html.AppendScriptParts("~/Scripts/public.ajaxcart.js"); Html.AppendScriptParts("~/Scripts/public.common.js"); Html.Ap

我正在研究nopCommerce,并注意到脚本和css以以下方式包含在Root_Head.cshtml文件中

Html.AppendCssFileParts("~/Content/smoothness/jquery-ui-1.8.17.custom.css"); 
Html.AppendScriptParts("~/Scripts/public.ajaxcart.js");
Html.AppendScriptParts("~/Scripts/public.common.js");
Html.AppendScriptParts("~/Scripts/jquery-ui.min.js");
Html.AppendScriptParts("~/Scripts/jquery.validate.unobtrusive.min.js");
Html.AppendScriptParts("~/Scripts/jquery.validate.min.js");
Html.AppendScriptParts("~/Scripts/jquery.unobtrusive-ajax.min.js");
Html.AppendScriptParts("~/Scripts/jquery-1.7.1.min.js");
在同一文档的后期,它被嵌入到头部:

@Html.NopCssFiles(this.Url, ResourceLocation.Head)
@Html.NopScripts(this.Url, ResourceLocation.Head)
这将生成html输出,以在页眉/页脚中嵌入脚本/css,如使用相对URL定义的那样

<link href="/Content/smoothness/jquery-ui-1.8.17.custom.css" rel="stylesheet" type="text/css" />
<script src="/Scripts/jquery-1.7.1.min.js"></script>

我需要将URL从插件更改为其他URL,而不修改根文件。因此,完成此操作后,它将如下所示:

<link href="http://someurl.com/Content/smoothness/jquery-ui-1.8.17.custom.css" rel="stylesheet" type="text/css" />
<script src="http://someurl.com/Scripts/jquery-1.7.1.min.js"></script>


你知道如何从插件扩展这个功能吗?我应该如何继续?

我不确定nopCommerce是如何工作的,但是如果您使用MVC4,那么您可以使用一个新的功能调用捆绑和缩小

一个最大的优点是,这将把所有的js和css合并到一个文件中并进行缩小,因此它将提高网站的性能

参考:

在BundleConfig.cs中,您可以执行以下操作

        var domainUrl = "http://someurl.com"; // you can retrieve it from config file

        bundles.Add(new StyleBundle(domainUrl + "/Content/css").Include( domainUrl + "/Content/site.css"));


        bundles.Add(new StyleBundle(domainUrl + "/Content/themes/base/css").Include(
                    domainUrl + "/Content/themes/base/jquery.ui.core.css",
                    domainUrl + "/Content/themes/base/jquery.ui.resizable.css",
                    domainUrl + "/Content/themes/base/jquery.ui.selectable.css",
                    domainUrl + "/Content/themes/base/jquery.ui.accordion.css",
                    domainUrl + "/Content/themes/base/jquery.ui.autocomplete.css",
                    domainUrl + "/Content/themes/base/jquery.ui.button.css",
                    domainUrl + "/Content/themes/base/jquery.ui.dialog.css",
                    domainUrl + "/Content/themes/base/jquery.ui.slider.css",
                    domainUrl + "/Content/themes/base/jquery.ui.tabs.css",
                    domainUrl + "/Content/themes/base/jquery.ui.datepicker.css",
                    domainUrl + "/Content/themes/base/jquery.ui.progressbar.css",
                    domainUrl + "/Content/themes/base/jquery.ui.theme.css"));

        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js"));
然后在cshtml中,可以使用以下方法

@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/jquery")
*编辑*

对不起,我只是重新看了一下答案,我可以这样做

在web.config中

<configuration>
    <appSettings>
        <add key="resourcePath" value="http://someurl.com"/>
    </appSettings>
 . . .
</configuration>

我不确定nopCommerce是如何工作的,但如果您使用MVC4,那么您可以使用一个新的功能调用捆绑和缩小

一个最大的优点是,这将把所有的js和css合并到一个文件中并进行缩小,因此它将提高网站的性能

参考:

在BundleConfig.cs中,您可以执行以下操作

        var domainUrl = "http://someurl.com"; // you can retrieve it from config file

        bundles.Add(new StyleBundle(domainUrl + "/Content/css").Include( domainUrl + "/Content/site.css"));


        bundles.Add(new StyleBundle(domainUrl + "/Content/themes/base/css").Include(
                    domainUrl + "/Content/themes/base/jquery.ui.core.css",
                    domainUrl + "/Content/themes/base/jquery.ui.resizable.css",
                    domainUrl + "/Content/themes/base/jquery.ui.selectable.css",
                    domainUrl + "/Content/themes/base/jquery.ui.accordion.css",
                    domainUrl + "/Content/themes/base/jquery.ui.autocomplete.css",
                    domainUrl + "/Content/themes/base/jquery.ui.button.css",
                    domainUrl + "/Content/themes/base/jquery.ui.dialog.css",
                    domainUrl + "/Content/themes/base/jquery.ui.slider.css",
                    domainUrl + "/Content/themes/base/jquery.ui.tabs.css",
                    domainUrl + "/Content/themes/base/jquery.ui.datepicker.css",
                    domainUrl + "/Content/themes/base/jquery.ui.progressbar.css",
                    domainUrl + "/Content/themes/base/jquery.ui.theme.css"));

        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js"));
然后在cshtml中,可以使用以下方法

@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/jquery")
*编辑*

对不起,我只是重新看了一下答案,我可以这样做

在web.config中

<configuration>
    <appSettings>
        <add key="resourcePath" value="http://someurl.com"/>
    </appSettings>
 . . .
</configuration>

谢谢你的回答,但是我需要在不改变核心文件的情况下从插件中更改URL。我该怎么做?你的意思是你不想对Root\u Head.cshtml进行任何更改?确切地说,我不想对Root\u Head.cshtml文件进行任何更改。谢谢你的回答,但我需要在不更改核心文件的情况下更改插件的URL。我该怎么做?你是说你不想对Root\u Head.cshtml做任何更改?确切地说,我不想对Root\u Head.cshtml文件做任何更改。