有没有一种方法可以跨应用程序使用ASP.NET捆绑软件 [英] Is there a way to use ASP.NET Bundles cross applications

查看:62
本文介绍了有没有一种方法可以跨应用程序使用ASP.NET捆绑软件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ASP.NET Web优化包来捆绑和缩小javascript / css文件。

I use the ASP.NET Web Optimization package to bundle and minify javascript/css files.

我有一些使用相同javascript / css文件的ASP.NET应用程序,现在我在每个应用程序中都设置了捆绑包。

I have a few ASP.NET applications using same javascript/css files, and now I setup bundles in each application.

我想知道是否有一种方法可以在其中一个应用程序中注册捆绑包,而其他应用程序只是使用它。

I wonder if there is a way to register bundles in one of these applications, and other applications just use it.

关键问题是如何在注册捆绑软件的应用程序之外的其他应用程序中获取查询字符串的哈希码。

The key problem is how to get the hash code of the query string in other application than the app in which bundles are registered.

推荐答案

您可以执行以下操作:

var domain="http://www.google.com";

Styles.DefaultTagFormat = "<link href=\"" + domain + "{0}\" rel=\"stylesheet\"/>";
Scripts.DefaultTagFormat = "<script src=\"" + domain + "{0}\"  type=\"text/javascript\"></script>";

当您致电时:

Styles.Render("~/masterpagecss")

Scripts.Render("~/masterpagejstop")

这将如下所示:

<link href="http://www.google.comm/masterpagecss?v=cUYMJ2uO6cjidXEjFnWzUVvVS4_GR9OGA45p3oKZJSQ1" rel="stylesheet"/>

<script src="http://www.google.com/masterpagejstop?v=Oay1Ofn63qSMuPEhfoMe9tPsA_Hp9HeG2rAEcaA6RWk1"></script>

我在我的网站上尝试了一下,效果很好。

I tried it in my web site and it worked perfectly.

只需确保您使用的域是您网站的绑定,我们就可以访问文件。

Just make sure that the domain that you used is a binding of your web site, in that we can have access to the files.

这篇关于有没有一种方法可以跨应用程序使用ASP.NET捆绑软件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆