我有下面的代碼,它工作正常。假設我現在想改變ActionLinkButton
方法中的某些內容,例如爲其簽名添加另一個 參數。當然,我也必須改變.cshtml中的調用。但是,如果我不更改 .cshtml,則應用程序僅在嘗試顯示View
時崩潰,並且定向到默認錯誤的html頁面,所以沒有編譯錯誤。日誌中沒有錯誤的詳細信息螢火蟲,任何地方。 顯然,當我做出這樣的改變時,我應該儘量記得檢查所有的電話,但我忘記了。
那麼,我該如何防止這個錯誤或使其更易於追蹤?
1.某種形式的Razor語法檢查器?
2.通過一些有意義的消息引導到錯誤頁面的一些方法?預防或剃刀錯誤的詳細信息
的.cs
public static MvcHtmlString ActionLinkButton(
this HtmlHelper htmlHelper,
string buttonText,
string actionName,
string controllerName,
RouteValueDictionary routeValues,
Boolean enable)
{
string href = UrlHelper.GenerateUrl("default", actionName, controllerName, routeValues, RouteTable.Routes, htmlHelper.ViewContext.RequestContext, false);
// title is tooltip
string buttonHtml;
if (enable)
{
buttonHtml = string.Format("<input type=\"button\" title=\"Export\" value=\"{0}\" onclick=\"location.href='{1}'\" class=\"button\" />", buttonText, href);
}
else // disable button
{
buttonHtml = string.Format("<input type=\"button\" disabled=\"disabled\" title=\"Export\" value=\"{0}\" onclick=\"location.href='{1}'\" class=\"button\" />", buttonText, href);
}
return new MvcHtmlString(buttonHtml);
}
.cshtml
@Html.ActionLinkButton(
buttonText: "Export",
actionName: "Export",
controllerName: "Detail",
routeValues: new RouteValueDictionary(new {PermitId = @Model.PermitId }),
enable : false)
你有沒有調試你的代碼,驗證方法的參數可能是這裏的錯誤。 –
編輯Web.config文件以關閉customErrors模式。 – Casey
是的,這確實提供了準確的信息。謝謝。我有Web.Debug.config文件設置爲關閉,但這是不夠的。我必須在Web.config中完成。 –