I think the key factor here is whether you want your users to “play with the code”
, - this ( @Caspar) css. css, W3 CSS Validator ( @Trikks).
Css. , ( , , ..), , . javascript , ( ..).
, -, - .
.net Css-. , Less, , asp.net mvc.
Css ( @Darin Dimitrov):
public class CssResult : PartialViewResult {
public override void ExecuteResult(ControllerContext context) {
context.HttpContext.Response.ContentType = "text/css";
base.ExecuteResult(context);
}
}
( ):
[HttpGet]
public ActionResult Index()
{
var styles = new Dictionary<string, string>()
{
{ "color", "red" },
{ "font-family", "Consolas, Courier, Serif" },
{ "font-size" , "12px" }
};
return this.Css(styles);
}
(views/css/index.cshtml):
body {@foreach (var item in Model) {
@string.Format("{0}: {1};", item.Key, item.Value)
}
}
. , , dom/class/id.
, , Url.Action("index", "css").