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

发布于 2024-07-26 00:31:21 字数 816 浏览 5 评论 0原文

我在 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?

I have Elmah up and running in my ASP.NET MVC site and I would like to integrate its interface with the administration pages of the site. By default, you invoke the interface with the url ~/elmah.axd, which runs outside the MVC system. The installation requires you to tell MVC to ignore the route, so there's no controller or anything that knows about elmah. The installation suggest a specific ignore, even though it is already ignored by default:

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

I would like to try integrating elmah.axd as a component of the site. I'm thinking to have a Elmah controller with a view that uses the Futures helper Html.RenderRoute but I'm not sure what arguments to pass:

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

Does this make sense - is there a way to pass the url in to Html.RenderRoute? Is there a better way that doesn't use Html.RenderRoute?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

咋地 2024-08-02 00:31:21

在你的视图中试试这个:

<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>

Try this in your View instead:

<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>
各空 2024-08-02 00:31:21

或者您可以在您的网站上使用此

Elmah 错误日志应用程序

or you can use this on your site

Elmah Error Log Application

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文