(searched - found this, this and this - which return CSS from a file or use 3rd party plugings, my needs are simpler). I am not looking to serve a Css from a file
I am building simple CSS blocks on the fly in the ASP controller, and I want to append it to the end of the page & prevent caching since it changes often.
Question: Why does the dynamic CSS block not render in the page/ MVC View call not work, anything I can do to help debug this?
In my ASP MVC razor View @Section
:
//Page stuff... at the very bottom of my MVC Razor view
//..
//Append my custom CSS styles
@section stylesSection {
<styles>
// is this not correct, why does the browser not load this??
<link href="@Url.Action("GetDynamicCssBlock", "DynamicCssCtlr")" rel="stylesheet" type="text/css" /> //updated with type type="text/css"
</styles>
}
My custom Css block Controller which serves the raw CSS content
, that
public class DynamicCssCtlr: Controller
{
public ContentResult GetDynamicCssBlock()
{
//string cssBlock = GetCssBodyFromDb();
//simplified...
string cssBlock = @".pDiv { background-color: yellow; }";
return Content(cssBlock , "text/css");
}
}
Is my link/content type wrong, or should this be in the head styles section? why does it not render, is my content type or return type wrong?