ASP.NET MVC Exchange JavaScript files from a class library

I am creating two ASP.NET MVC sites. There is a certain amount of content that I want to have in order to share between the two sites. I created a class library and was able to share much of what I needed. However, I would really like to know how I can share content such as images and JavaScript files, so I do not need to duplicate them between both websites.

I would really appreciate it if anyone has any good ideas on this.

+3
source share
4 answers

You can use CDN (Content Delivery Network) for shared files.

<script src="http://shared.yourdomain/stuff.js" type="text/javascript"></script>

, SO, , 2 . CDN , 2 CDN. . , js.yourdomain img.yourdomain, .

+2

, -. - .

+2

javascript url src JavaScript. .

<script src="some_url_path_/global.js" type="text/javascript"></script>

, -, .

+1

Javascript files and images can be placed in a common place - for standard javascript files (jquery library, etc.) it is recommended to use CDN, as Kiron points out, you get many advantages there.

For other content files, you can simply place them on a common URL that both sites access - for example. with two sites at different URLs:

http://site1.somedomain.com/default.aspx
http://site2.somedomain.com/default.aspx

they can use content from a common location, for example:

http://commoncontent.somedomain.com/images/bigimage1.jpg
http://commoncontent.somedomain.com/scripts/customjavascript1.js

The same thing works with virtual directories, not fqdn.

+1
source

Source: https://habr.com/ru/post/1706804/