In my ASP.NET Webforms project, my global.asax
inherits it's implementation from a class library. Now I would like to implement Bundling and magnification of JS and CSS for my Web project.
Few options that I can think of
- Create a common shared folder on my solution and add all JS and CSS physical files there and add reference path (as add existing item) in my
class library project
and use those paths for bundling. - Developers need to add new file at common folder and add existing item path to Web/other projects, hence redundant steps. - Write a pre-build event on my Web Project, that will do a x-copy to copy over all scripts from webproject to Class Library project - This will add redundant content o server
- Add a abstract class in webproject that inherits from class library to class, and add bundling stuff in web project.
Is there any better way to handle this situation?
IIS Structure
- Main Site
- global.asax (inherits SubSite global Class)
- all other files
- SubSite
- global.asax (calls BundlingClass RegisterBundles method)
- scripts folder
- all other stuff
- BundlingClass
- ASPX pages (all ASPXs are here)
URL: www.MainSite/SubSite/HomePage.aspx
code in Homepage.aspx
<asp:PlaceHolder runat="server">
<%: Scripts.Render("~/ScriptsBundle/mainjs")%>
</asp:PlaceHolder>
This is rendering
<script type="text/javascript" src="/ScriptsBundle/mainjs"></script>
And that is giving 404. How can I resolve this.