URL Rewriting And Links In Your ASPX Pages

posted on 10/30/07 at 10:17:40 pm by Joel Ross

Last night, I was adding a new feature to Tourneytopia to allow in-place editing of content. Once published, you'll be able to pop a modal dialog with a text editor in it, update the content, click update, and see it updated on the page immediately.

But when I got it developed and started to test it, I got a 500 server code returned to me. Removing the UpdatePanel, I was able to see the real issue. It said it couldn't find the supporting files it needed. Looking at the editor in the ASPX page, we have this line:

<ftb:FreeTextBox id="editor" runat="server" Width="600px" height="400px" SupportFolder="~/FreeTextBox.axd" />

The problem, as it turns out, is that last attribute. That, combined with the fact that we use URL rewriting for all of our pool pages for the site. I've run into this in the past, but with images. Anytime an image has it's URL specified in the page, URL rewriting will cause a problem. Basically, when you specify the URL in the ASPX part of the page, it will create an path that doesn't take into account the rewritten path - the one the browser will use to resolve paths to the images.

To solve the issue, you simply set the property in the code behind, and all is well:

protected void Page_Load(object sender, EventArgs e)
= "~/FreeTextBox.axd";

By setting it in the code behind, the path will be set properly. Once I did this and added the UpdatePanel back in, my editor worked, and we now have a much better content management experience for March.

Categories: Develomatic, Development, C#