On my ASP.NET MVC website, people can choose between different CSS styles. In the future, the name of these css styles will be stored in the database.
I have the following method (not yet database related):
public FileResult CssStyle()
{
string style = "/Content/wide-site.css";
if (!String.IsNullOrWhiteSpace(style))
{
return File(style, "text/css");
}
return File("/Content/site.css", "text/css");
}
And in my _Layout.cshtml, I use this line to load the stylesheet:
<link href="@Url.Action("CssStyle", "Home")" rel="stylesheet" type="text/css" />
Assume that this CssStyle () method executes a query on a database, and for each page load it executes a query. What is the best way to prevent these unnecessary requests? Perhaps a session?
user1613714
source
share