【发布时间】:2012-09-21 09:38:26
【问题描述】:
我开始使用MiniProfiler,发现它在开发我的 MVC 4 应用程序时非常有用。
但是,我刚刚在一个相当复杂的项目中添加了一个新的控制器操作和视图,现在 MiniProfiler 在控制器返回控制后抛出一个异常。
异常文本是路径中的非法字符。
调用栈位置是
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。关于如何让它再次工作的任何想法?
【问题讨论】: