Tuesday, February 10, 2009

Ugly .Net Bug - asp:hyperlink

Recently, my crew and I ran across one of those painful bugs that takes up too much time. Ultimately, we marked it up to an ASP.NET problem. Here are the details.

We have several environments set up at work ranging from our local/developer system to our production system. In only one of our environments, the navigation in our application would disappear when a postback would occur. We use master pages and several user controls throughout the site. However, since nearly every page that performed a postback experienced the problem, we narrowed our search to the master page. Why didn't we just attach and run the application in debug mode you ask? Well, as it turns out the local environment did not exhibit the behavior. Talk about bringing debugging back to the 90s.

Further logging and testing limited the focus to the Page_Load inside the master page. Setting test points throughout the method, we narrowed it down to some extremely inconspicuous code. Here is an example of that code (obviously not the real code):

hlNav1.NavigateUrl = hlNav1.NavigateUrl.Contains("xyz") ? hlNav1.NavigateUrl : hlNav1.NavigateUrl + "&xyz=123";
hlNav2.NavigateUrl = hlNav2.NavigateUrl.Contains("xyz") ? hlNav2.NavigateUrl : hlNav2.NavigateUrl + "&xyz=123";
hlNav3.NavigateUrl = hlNav3.NavigateUrl.Contains("xyz") ? hlNav3.NavigateUrl : hlNav3.NavigateUrl + "&xyz=123";
hlNav4.NavigateUrl = hlNav4.NavigateUrl.Contains("xyz") ? hlNav4.NavigateUrl : hlNav4.NavigateUrl + "&xyz=123";
hlNav5.NavigateUrl = hlNav5.NavigateUrl.Contains("xyz") ? hlNav5.NavigateUrl : hlNav5.NavigateUrl + "&xyz=123";

As it turns out, we tried several variations of that code. Checking for null, empty, converting to an if statement, blah blah blah. We even wrapped the code above in an "if (!Page.IsPostBack)," to no avail. Here is where it gets interesting. The first time this code executes, it works perfectly. However, in this particular environment, the code blanks out any child entities when you replace the NavigateUrl (only during a postback). We had a <div> inside of each asp:HyperLink which ended up being nuked.

The solution, get rid of asp:HyperLink and use a plain old <a href="" runat="server">. How Glamorous.

At any rate, I hope this keeps someone else from burning time.

Posted via email from A Bit of Everything

Wednesday, January 28, 2009

The Linking of the Blogs


I have been resisting combining blogs and posting everywhere, but no longer. This is my first attempt at creating a publish-once post-everywhere entry. I wouldn't alter what I've been doing for so long, but lately I've been looking into Posterous. Although there aren't many options to customize the interface, Posterous is a simple blogging tool that has very powerful capabilities. For instance, if I attach an image (as I have in this example), it auto-posts it. The same holds true for video and audio. These days a blog must have native image, video, and audio support. Readers want pizaz and they can get it.

So, I guess it's time to grow up and move on. Well, maybe not move on. Posterous also allows me to auto post to Blogger and it also retains the images for my entry. It's just a win/win situation. Oh, and the picture is from Tarantinos, a local pizza joint who happens to be advertising their MySpace page.

Posted via email from ctcoley's posterous

Thursday, January 22, 2009

Wow, where did the time go?!

Well, my blog has been slightly neglected lately. I typically make a point of posting every month but I missed December. Mainly, we are cooking some exciting changes at work and I can't discuss them too much. Well, technically I've already said too much.

At any rate, we do have some great things coming and I plan on highlighting a few of the tech pieces here after the next release.

Sunday, November 09, 2008

Server Not Found? Lovely.

Well, I recently experienced the most excellent error on my blog of "Server Not Found 404 Error." First off, I did nothing to create the error. I'm not sure if it was GoDaddy or Blogger that caused this joyful event. My blog has been running very nicely for several years. A couple of years ago (maybe only one and half, but who's counting?) I implemented the custom domain part of blogger with a domain I have had registered for a long time. Sometime a couple of weeks ago, the server not found error started hitting chadcoley.com, but worked fine if I typed in www.chadcoley.com. However, at some point everything quite working. Fine, I'll do the research and fix it.

As it turns out, I read several other blog posts of people having similar issues. The most helpful post was from a Google group which says something about adding another A record in DNS. As it turns out, I did some comparing to other sites hosted at Blogger using GoDaddy and had to had a new A record to DNS in GoDaddy's Total DNS Control form. Oddly enough, it was a hardcoded IP Address I have never seen before. Here is now my new A record list in DNS:

ARecord @ 72.14.207.121
ARecord @ 64.233.179.121

I have never touched the 72.14.207.121 address before. Once I added the 64.233.179.121 IP I had to turn off custom domain handling through Blogger. Finally, I turned custom domain handling back on and, like magic, it worked. Ok, not quite magic, more like pain.