MiniProfilerの使用を開始しましたが、MVC 4 アプリケーションの開発中に非常に役立つことがわかりました。
しかし、かなり複雑なプロジェクトに新しいコントローラー アクションとビューを追加したところ、コントローラーから制御が戻った後に MiniProfiler が例外をスローするようになりました。
例外テキストはIllegal Character in Pathです。
コールスタックの場所は
MiniProfiler.dll!StackExchange.Profiling.MVCHelpers.ProfilingActionFilter.OnActionExecuted(System.Web.Mvc.ActionExecutedContext filterContext) 行 58
私のコントローラーのアクションとビューはどちらも非常に単純です。
コントローラーのアクション
[AllowAnonymous]
public ActionResult ReleaseNotes(string name)
{
CheckInput(name);
string notesPath = Server.MapPath("~/Content/ReleaseNotes/" + name + ".html");
string notes = null;
if (System.IO.File.Exists(notesPath))
{
notes = System.IO.File.ReadAllText(notesPath);
}
return View(notes);
}
private void CheckInput(string name)
{
if (name.Length > 0x100 || !name.IsAlphaNumeric()) throw new ArgumentException("Name is invalid.");
}
注: System.IO.File.ReadAllTextは、HTML ファイルの内容を正常に読み取ります。そのパスは有効です。
意見
@model string
@{
ViewBag.Title = "Release Notes";
}
<h2>Release Notes</h2>
@if (string.IsNullOrWhiteSpace(Model))
{
<p>No release notes were found for the specified release.</p>
}
else
{
@Html.Raw(Model)
}
今のところ MiniProfiler を無効にしています。再び機能させる方法について何か考えはありますか?