如何在Windows MVC站点中集成axd(Elmah)作为组件

kei*_*thm 7 asp.net-mvc elmah health-monitoring asp.net-mvc-futures

我在我的ASP.NET MVC站点中启动并运行Elmah,并且我希望将其界面与站点的管理页面集成.默认情况下,您使用url~/elmah.axd调用接口,该接口在MVC系统外部运行.安装要求你告诉MVC忽略路由,所以没有控制器或任何知道elmah的东西.安装建议特定忽略,即使默认情况下已被忽略:

public class MvcApplication : System.Web.HttpApplication {
    public static void RegisterRoutes(RouteCollection routes) {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
        routes.IgnoreRoute("elmah.axd");
...
}
Run Code Online (Sandbox Code Playgroud)

我想尝试将elmah.axd集成为网站的一个组件.我想有一个Elmah控制器,其视图使用Futures助手Html.RenderRoute,但我不确定要传递的参数:

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Elmah</h2>
    <% Html.RenderRoute(???); %>
</asp:Content>
Run Code Online (Sandbox Code Playgroud)

这是否有意义 - 有没有办法将网址传递给Html.RenderRoute?有没有更好的方法不使用Html.RenderRoute?

eu-*_*-ne 7

请在您的视图中尝试此操作:

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Elmah</h2>
    <iframe src="<%= Url.Content("~/elmah.axd") %>" frameborder=no width=100% scrolling=auto>
    </iframe>
</asp:Content>
Run Code Online (Sandbox Code Playgroud)