Running Elmah within an existing site

6 views
Skip to first unread message

DSCODUC

unread,
Apr 14, 2008, 6:14:32 PM4/14/08
to ELMAH
My blog (Blogengine) has an administration section that includes admin
pages. I would like to nest ELMAH into this solution. Is there any
suggestions on how best to accomplish this task?

Thanks.

Chris

Eric

unread,
Apr 14, 2008, 7:13:18 PM4/14/08
to ELMAH
First add ELMAH to your blog engine (-> see Doc how to do it)

Second, to show the logs directly in your admin page, you have some
possibilities.
Use the RSS feed or direct db access to list the errors or render the
errors into your page (see ErrorDetailPage.cs / ErrorHtmlPage.cs).

If necessary, secure the access to ELMAH.

Eric

DSCODUC

unread,
Apr 15, 2008, 12:02:01 AM4/15/08
to ELMAH
Thank you for responding. Might be a dumb question as I am not a
developer, but is it possible to make the Elmah pages render in a user
control? Then I could drop the user control into any page I wanted.
Would that be very difficult to achieve?

Atif Aziz

unread,
Apr 15, 2008, 4:33:27 PM4/15/08
to el...@googlegroups.com
>>
but is it possible to make the Elmah pages render in a user
control? Then I could drop the user control into any page I wanted.
Would that be very difficult to achieve?
<<

I don't think it would be difficult to achieve and would require very little programming. You could, for example, that an XmlDataSource and point it to the RSS feed from ELMAH. Then you bind a control to the XmlDataSource and format the channel at your will.

The data source declaration would look something like this (replace the DataFile property value with the URL of where your ELMAH's RSS feed resides):

<asp:XmlDataSource
ID="ErrorLogRssDataSource" runat="server"
DataFile="http://www.example.com/elmah.axd/rss"
XPath="rss/channel/item" />

Next you could bind a simple repeater to this source:

<asp:Repeater
runat="server" ID="ErrorRepeater"
DataSourceID="ErrorLogRssDataSource">
<HeaderTemplate><dl></HeaderTemplate>
<ItemTemplate>
<dt><a href='<%# XPath("link") %>'><%#
Server.HtmlEncode(XPath("title").ToString()) %></a></dt>
<dd><%# Server.HtmlEncode(XPath("description").ToString()) %></dd>
</ItemTemplate>
<FooterTemplate></dl></FooterTemplate>
</asp:Repeater>

Adding those two to a page should do it and adding the same to a user control should also work. I've attached a sample page that demonstrates this stuff in action.

HTH,
Atif

ErrorLogView.aspx
Reply all
Reply to author
Forward
0 new messages