Domanda

I have 2 projects ABC and XYZ created as 2 separate Virtual Directories in IIS (7). Now my problem is I have many .JS (script) files in project XYZ that need to be bundled and minfied and rendered in an aspx page (containing HTML code) that is available in project ABC. Is this possible ?

Note: Using Microsoft ASP.NET Web Optimization Framework 1.1.1

[http://www.nuget.org/packages/microsoft.aspnet.web.optimization/]

È stato utile?

Soluzione

Yes, just use the correct link to the bundle in your other project.

If you bundle is for example defines as

 bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js"));

which can get accessed via

 @Scripts.Render("~/bundles/jquery")

you can use

 <script src='http://<host>/<site>/bundles/jquery' type='text/javascript' language='javascript' />

Just as simple as that.

If you have both applications installed on the same website (same root), you can also use relative URLs, e.g.

<script src='/XYZ/bundles/jquery' type='text/javascript' language='javascript' />
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top