开发者

Sharing CSS, JS, images, master pages, etc across ASP.NET web sites

I need to share those types of resources across several ASP.NET web sit开发者_Python百科es. The approach I tend to is to create separate web application for common master pages and separate web site for common CSS, images, etc. The problem here is that I will no more be able to reference common resources using tilde, instead I would have to use URL of common web site with those resources.

There is also an approach delegating source control to manage this which I don't like because you would have to check in changes and update other web sites for changes to take effect.

Are there any better ways of sharing those resources across ASP.NET web sites?


You could add the common resources project to your solution, set up a pre-build event command line in the common resources project to copy the files to a directory in the solution you are working in and then create a project reference to the common resources project so it will copy each time you build the project that needs the resources.

I use it to share ASP.NET Usercontrols between a few projects. The idea is described here: http://weblogs.asp.net/scottgu/archive/2005/08/28/423888.aspx.

Here is an example what you can put in the pre-build event in the common resources project:

if exist $(SolutionDir)\SharedDir\ xcopy $(ProjectDir)\Resources\*.* $(SolutionDir)\SharedDir\ /c /y /d
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜