views:

263

answers:

2

I have ELMAH setup on my production server and it has done a fantastic job of letting me know about any niggles - as well as any creative SQL injection!

I've decided to introduce URl Rewriting and went for http://www.urlrewriting.net/ in the end. It was nice and easy to setup and it's doing exactly what I want with the customer-facing site.

The problem is ELMAH. Because I've set the urlrewritingnet node in my config like so:

<urlrewritingnet
  rewriteOnlyVirtualUrls="true"
  contextItemsPrefix="QueryString"
  defaultPage = "default.aspx"
  defaultProvider="RegEx"
  xmlns="http://www.urlrewriting.net/schemas/config/2006/07" >

...ELMAH likes to do this to it's axd links;

http://www.mydomain.com/elmah.axd/stylesheet/default.aspx

Does anyone have any idea how to either a) stop the re-writer following the .axd; or b) add rules to the re-writer to get ELMAH to work

Any ideas? I'm happy to hack about with the httpHandlers...

A: 

I kind of solved this, but not in the way I wanted too. For the reference of others, I will provide a breakdown of what I did and the resources;

ELMAH: http://code.google.com/p/elmah/ URLRewritingNet: http://www.urlrewriting.net/149/en/home.html

This was really the only available option to me: http://csharpin.blogspot.com/2009/03/using-urlrewritingnet-and-elmah.html, but I had untold difficulty to get the code into my existing architecture without other adverse affects. I did try adding rules to the ExternalRewrite.config (URL Rewrite) to ignore *.axd, but that didn't pan out either. I was getting all sorts of weird behaviour.

I then decided to use Health Monitoring: http://www.4guysfromrolla.com/articles/031407-1.aspx instead of ELMAH. Sorry ELMAH :(

Health Monitoring was a snip to setup and then all I had to do was solve the nasty postback problem on rewritten URLs;

Health Monitoring web.config;

<!--he-mon-->
    <healthMonitoring enabled="true">
      <eventMappings>
        <clear />
        <add name="All Errors" type="System.Web.Management.WebBaseErrorEvent" startEventCode="0" endEventCode="2147483647" />
      </eventMappings>
      <providers>
        <clear />
        <add connectionStringName="healthMonitoringConnectionString" maxEventDetailsLength="1073741823" buffer="false" name="SqlWebEventProvider" type="System.Web.Management.SqlWebEventProvider" />
        <add type="System.Web.Management.SimpleMailWebEventProvider" name="EmailWebEventProvider" from="xxx" to="yyy" bodyHeader="zzz" bodyFooter="000" buffer="false" />
      </providers>
      <rules>
        <clear />
        <add name="All Errors Default" eventName="All Errors" provider="SqlWebEventProvider" profile="Default" minInstances="1" maxLimit="Infinite" minInterval="00:00:00" />
        <add name="All Errors Default Email" eventName="All Errors" provider="EmailWebEventProvider" profile="Default" minInstances="1" maxLimit="Infinite" minInterval="00:00:00" />
      </rules>
    </healthMonitoring>
    <!--he-mon-->

Add the connection string to the connectionString node too.

To fix the rather nasty postback on URL rewritten strings, I tried ScottGu's suggestion; Handling ASP.NET PostBacks with URL Rewriting: http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx, but I couldn't get that to work at all.

Starting to really regret getting into URL Rewriting, I finally added this to the one problematic page I had; Me.Form.Action = Me.Request.RawUrl within the Page_Load and it worked a treat.

I know this doesn't directly answer the question, but I hope it helps. I hope someone finds my information at least somewhat useful.

Chris Laythorpe
I've got a solution for you below, if you ever wish to revert back to UrlRewritingNet.
subkamran
+1  A: 

Hi,

I came up with a simpler solution if others are interested.

I just modify the source code directly and add in some basic logic to ignore specific rewrite rules.

subkamran
I can't test this, but it looks pretty good actually. I am impressed. If I get a spare moment I might load it back onto a UrlRewritingNet and ELMAH project... Thanks. +1
Chris Laythorpe
My site right now directs every request through .NET, so when people visit http://intrepidstudios.com/tutorials/web%201001 URLRewriterNet will intercept it and serve "default.aspx" rather than index.html.I added a rule to my config and voila, it works! <add name="Tutorials" virtualUrl="^~/tutorials/(.*)$" rewrite="None" />
subkamran