ASP.NET Themes and Static Content

as you all know, ASP.NET includes every CSS stylesheet in the Theme App_Themes folder on the page. No discussion.

But now I have a little problem with a lot of CSS files in the subject and I want to use a static content domain . I would like to download all the static content of my site from a static domain (not only CSS, but also icons, images, etc.), but now pay attention only to CSS.

My question

Is it possible to override the behavior of the Page class and for each CSS file found in the Subject folder, rewrite the <link> with the correct URL for the static content domain? I have nothing to prevent me from deploying files to http://static.domain.com/App_Themes/Theme , so at least adding the prefix to the tag is fine.

Thanks in advance.

+3
source share
2 answers

An alternative method is to write an http module. Ask the module to check if html is being sent to the client.

If it finds a link in the stylesheet, change the location from which the stylesheet is erased.

This works for other items such as images, etc.

0
source

Yes, you can. You can create your own class of base pages that will record CSS files found in the folder. Although, I'm not sure that you can override the default behavior for the theme, so the easiest way is to move the CSS files outside of the standard themes. You can then use System.IO objects to read the directory, access the file, and create the link.

NTN.

+1
source

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


All Articles