This is just one way - depends on how extensive (or not) the changes are: leverage sections
You'll typically have in boilerplate that shows @section that are "placeholders" for anything you want to "inject" from View.
Example:
Views/Shared/_Layout.cshtml define an optional Section in <head />
<title>@ViewBag.Title</title>
<!--this could be your "base" style-->
@Styles.Render("~/Content/css")
<!--this could be your "override" style-->
@RenderSection("OverrideStyles", false)
in a View or _ViewStart (so you can style multiple views in one place) use it as needed
@section OverrideStyles
{
@if (DateTime.Now.Second % 2 == 0) //Some expression or some value from controller....
{
<style>
div.jumbotron h1 {
color: #ff0000;
}
</style>
}
else
{
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/stackoverflow/all.css?v=693004a3f56e">
}
}
<div class="jumbotron">
<h1>ASP.NET</h1>
<p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS, and JavaScript.</p>
<p><a href="http://asp.net" class="btn btn-primary btn-lg">Learn more »</a></p>
</div>
You can expand from there - even dynamically set entire _Layout if necessary..
e.g. _ViewStart.cshtml
@{
if (DateTime.Now.Second % 2 == 0)
{
Layout = "~/Views/Shared/_Layout.cshtml";
}
else
{
Layout = "~/Views/Shared/_Layout-bar.cshtml";
}
}
Hth...
style.css?version=3.2