I am trying to get ASP.NET Bundling to change the way it generates paths for JS/CSS bundles. If my site is hosted on http://example.com/myapp
and i use Scripts.Render("~/bundles/js") and Styles.Render("~/bundles/css"), this is what i get:
<script src="/myapp/bundles/js?v=RYQkGlZ5kEreOyiFPLgJ2SkEJtBEjiJQ6NeuVTYwXMY1"></script>
<link href="/myapp/css?v=1FC5SbQ1-E0J4ZXC1coG1W09-2uMUsJx0S1y_amIU3U1" rel="stylesheet"/>
Instead, if through some DNS magic we can enable the user to use the URL http://myapp
- although it's still hosted at http://example.com/myapp
- I would like the script/style bundles to render URLs like this:
<script src="bundles/js?v=RYQkGlZ5kEreOyiFPLgJ2SkEJtBEjiJQ6NeuVTYwXMY1"></script>
<link href="bundles/css?v=1FC5SbQ1-E0J4ZXC1coG1W09-2uMUsJx0S1y_amIU3U1" rel="stylesheet"/>
Is there a workaround for this? I don't think that Scripts.RenderFormat or Styles.RenderFormat will help with this.
System.Web.Optimizations
assembly, it seems like it's pretty hard coded. Unless you want to reinvent the wheel, I think the application relative path is required. There could be something I'm not seeing though. – Steven V