Load css dynamically in asp.net?

后端 未结 3 1812
借酒劲吻你
借酒劲吻你 2020-12-17 01:33

I\'m creating a content management system where a user can select a css file from their server and the application will parse and store the css. The application will need t

3条回答
  •  眼角桃花
    2020-12-17 02:32

    A good approach for a WebForms-only project is to link to an .ashx handler in your page instead of a static CSS file:

    
    

    Then create the handler (add a 'Generic Handler' item from Visual Studio) and within it you can load the CSS from a database or wherever. Just make sure you set the content type correctly in the handler, so that browsers recognise the response as a valid stylesheet:

    context.Response.ContentType = "text/css";
    

提交回复
热议问题