一部のビジネス ロジックに基づいて、layout.cshtml に動的に選択された CSS ファイルを設定するのに問題があります。
私のlayout.cshtmlには、headセクションに次のものがあります。
<head>
<link href="@{Html.RenderAction("CustomStyleSheetPath", "Shared");}" rel="Stylesheet" type="text/css" />
</head>
私の「共有」コントローラーには、次のものがあります。
[ChildActionOnly]
public virtual string CustomStyleSheetPath()
{
string customCssPath = GetCssPath(); // e.g. "css/customStyleSheet.css"
return customCssPath;
}
ページを表示すると、css が正しく取り込まれず、ソースを表示すると次のようになります。
<head>
<linkcss\customStyleSheet.css href="" rel="Stylesheet" type="text/css" />
</head>
このコードは MVC 3 で動作していたので、何が間違っているのでしょうか?