如何将axd(Elmah)作为组件集成到ASP.NET MVC站点中

7

我已经在我的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");
...
}

我想尝试将 elmah.axd 集成为站点组件。我考虑创建一个 Elmah 控制器,其中包含一个使用 Futures 帮助程序 Html.RenderRoute 的视图,但我不确定要传递哪些参数:

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

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

2个回答

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>

1
谢谢你,iframe很好用。我太专注于控制器等内容,忘记了直接使用HTML。 - keithm

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接