Making UrlRewritingNet Ignore URLs [Fix]

I recently updated the Intrepid Studios site back-end to include ELMAH, the error reporting module. ELMAH is great and works great, except that it doesn't play nice with UrlRewritingNet.

There is a StackOverflow discussion about this with a workaround that ended up not using UrlRewritingNet at all unfortunately. In addition, there's a detailed post about doing some voodoo and mixing potions to get UrlRewritingNet to work. Note that you can simply remove the defaultPage attribute on the urlrewritingnet config section to solve this, but it may cause other unintended consequences.

I thought to myself, there's gotta be a better way! And there is (well, it's a hack so I suppose it is not entirely the best, but it is the simplest so far). I simply added in a few lines of code to the UrlRewritingNet source code to allow you to ignore URLs. Without knowing much about how the component works, this is an easy "patch."

Download the Modified Binaries

For those that don't care how I did it, I have uploaded the modified binaries you'll need to replace in your application. See below for an explanation of how to use it.

Getting the Source

Head over to the Downloads section of UrlRewritingNet to get the source code.

Extract the files to a directory of your choice.

I opened and converted the solution with VS 2010, but you can use anything you wish.

Modifying the Files

We will modify 3 files. Follow along below.

In WebRewriteOption.cs, add another value to the enumeration like so:

[Flags] 
public enum RewriteOption
{
    Application = 0x00,
    Domain = 0x01,
    None = 0x02 // KR: Ignore the URL
}

In WebUrlRewriteModule.cs, around line 212, add the following underneath if (rewrite.IsRewrite(requestUrl)):

//KR: ignore url
if (rewrite.Rewrite == RewriteOption.None)
{
    rewritten = true; // sure, we totally "rewrote" it, heh.
    break;
}

In urlrewritingnet.xsd, change the xs:simpleType for RewriteOption to be:

<xs:simpleType name="RewriteOption">
  <xs:restriction base="xs:NMTOKEN">      
    <xs:enumeration value="Application" />
    <xs:enumeration value="Domain" />
    <xs:enumeration value="None" /> <!-- KR Ignore URL -->
  </xs:restriction>
</xs:simpleType>

Finally, in the same file, change the use="required" attribute of destinationUrl to be optional, like so:

<xs:attribute name="destinationUrl" type="xs:string" use="optional" />

Build the solution in Debug/Release and copy over the new DLLs to your project. Voila, all done! Now all you need to do to NOT rewrite a URL is the following:

<add name="Elmah"
  virtualUrl="^~/elmah.axd(.*)$"
  rewrite="None"
/>

I've tested it with Intrepid Studios and it seems to work just fine.

As always, feedback and improvements are much appreciated!

Update: jQuery Rich Text Editor [New Version]

image

A new minor update has been released to the jQuery Rich Text Editor with some new icons and an ASP.NET demo.

Changes

  • Added Silk icons for a nicer look
  • Added ASP.NET demo solution to test the script
  • Added extra function "$.rte.html".
  • Updated code to match latest changes in Google Code repo.
  • Note that this release contains BREAKING CHANGES because the options have all been renamed (see Documentation)

I tested the script with the latest jQuery release and it still works.

Let me know if you run into any trouble. I think it may still have some trouble with nested controls, which I will test soon, since my admin panel wasn't saving the text written in the control.

View the project homepage for the jQuery Rich Text Editor

Windows Phone 7 Quick Tip: Disable Hamachi [Tips & Tricks]

I ran into a problem while playing with the Windows Phone 7 CTP the other day. I was trying to use the Google data services via the WebClient object. It was throwing exceptions no matter what I did. I noticed it threw exceptions on ANY Google-hosted URI.

Long story short: disable Hamachi or any other potential virtual network adapters. VMWare seems to not interfere but Hamachi enjoys taking over connections sometimes and will hijack your phone emulator.

You can view the details of my adventure right over yonder.

Release: ASP.NET Picasa Photo Gallery + API [Project]

I've created a small package that allows .NET developers to easily consume the Picasa API and create a simple photo gallery. More »
An error has occured while trying to process your request. Hide