try-catch-FAIL

Failure is inevitable

NAVIGATION - SEARCH

ASP.NET MVC HtmlHelper for Uploadify, Take One

As I’ve mentioned before, I really, really hate the way most people seem to be creating reusable UI “controls” with ASP.NET MVC.  I do not like emitting JavaScript, HTML, etc. from within C# code.  It’s cumbersome to create, difficult to really test, and just a real PITA in general. Based on feedback I received from Rob after my attempts at creating a helper for jqGrid, I decided to take a completely different approach when it was time to wrap another jQuery plug-in: Uploadify.  My goal was to minimize the amount of tag-soup embedded in my C# code while still maintaining the ea... [More]

Using Flash with ASP.NET MVC and Authentication

There is a well-known bug in Flash that causes it to completely ignore the browser’s session state when it makes a request.  Instead, it either pulls cookies from Internet Explorer or just starts a new session with no cookies.  GOOD CALL, ADOBE.  And when I say this bug is well-known, I mean it was reported in Flash 8.  It’s still sitting in the Adobe bug tracker.  It has been triaged, it seems to have high priority, yet it remains unfixed.  Again, GREAT job, Adobe.  Anyway, why should you care?  Well, if you want to use Flash for anything, even someth... [More]

Testing SyntaxHighlighter

This is a test post to see how SyntaxHighlighter works with Windows Live Writer.  I’m using the PreCode plug-in. So, C#: public class Testing { public Id { get; private set; } public void Method(string parameter) { Console.WriteLine("Testing!"); } } And JavaScript: function(x,y) { alert('X is:' + x + " and Y is: " + y); } And SQL: SELECT * FROM Table WHERE Col1='Test' AND 1=0 HTML: <div> <h1>Something!</h1> <p>Something else!</p> </div>

&ldquo;Hi, we&rsquo;re Square Enix, and we are totally LAME!&rdquo;

This isn’t directly development-related, but it is noteworthy.  On May 8th, Square Enix, makers of Final Fantasy, Chrono Trigger, etc, hit Chrono Compendium with a cease-and-desist related to ROM hacking and modifications, particularly as it relates to the Crimson Echoes fan project.  Square Enix has sent C&D projects in the Chrono community before, but they were always to people that were recreating Chrono in a new engine/platform/whatever, not to groups that were creating ROM hacks.  ROM hacks are essentially nothing more than mods, which are standard fare these days. ... [More]

Correctly referencing jqGrid in ASP.NET MVC

Show of hands, how many of you are using jqGrid?  Alright, now how many of you have tried to run your ASP.NET MVC application in a configuration where the root of the application isn’t “/”? Alright, now raise your hand if you are having to edit jquery.jqGrid.js when you move the application to the alternate configuration?  NOTE: I’m assuming that your development environment runs with the application at the root of WebDev.WebServer.exe; if not, simply swap the assumptions, and I bet you still have the same problem I’m about to describe. If your hand is not up, congratulations, you... [More]

Introduction to Lucene.NET

This is the obligatory “introduction to something that I’m going to be talking about periodically” post.  I think a lot of developers (myself included until recently) are not familiar with Lucene/Lucene.NET and where it fits in their development toolbox.  By the end of this post, you should understand the basics of Lucene, and you will (hopefully) want to come back for future posts that will show you how to use Lucene in your applications. What is Lucene? Good question.  For that, I defer to the documentation: Apache Lucene is a high-performance, full-featured text search engi... [More]

Simplified unit testing for ASP.NET MVC JsonResult

There are quite a few examples floating around on the web that describe how to test your JsonResult objects to make sure the data was correctly packaged.  They all follow the same basic pattern: mock out core ASP.NET objects (such as ControllerContext, HttpResponse, and HttpContext), call JsonResult.ExecuteResult, recover what was written to HttpResponse.Output, and deserialize it.  Sure, this approach works, but in the same manner as cleaning your house out by lighting it on fire.  It’s way overkill.  There’s a much easier way.  For simple objects, just cast JsonResul... [More]

Prevent users from abandoning changes accidentally with jqGrid

In the project I’m working on, we use jqGrid to display hierarchical records in an Excel-like manner.  Changes are queued up on the client and submitted to the server whenever the user clicks the “Save” button.   That means a user could make a bunch of changes, then navigate away from the page accidentally, and lose everything they just did.  Preventing that is easy enough though, just use this JavaScript snippet: 1: window.onbeforeunload=checkForChanges; 2: function checkForChanges(){ 3: var rows = $('#treeTable').getChangedCells('all');... [More]

Link Roundup for May 6, 2009

Windows 7 RC Publicly Available The release candidate has arrived!  And it’s valid until March 1st!  The beta, however, begins shutting down on June 1st (less than a month for those who can’t read the title of this blog post).  If you’re running beta, get it.  Upgrading from beta to RC is described here, but it is not recommended.  Storing MVC views in a database Phil Haack has a good article on storing your ASP.NET MVC views in a database and rendering them without requiring full-trust.  This could be very useful for any system that needs to support custo... [More]

Things I hate&hellip;

The use of metadata classes: 1: [MetadataClass(typeof(MyMetadataClass))] 2: public partial class MyClass 3: { 4: public int MyProperty { get; set; } 5: } 6:  7: public class MyMetadataClass 8: { 9: [Range(1,100)] 10: public int MyProperty{ get; set; } 11: } [Credit goes to Mike’s post for inspiring this bit of hatred; I’m not blaming Mike for the hate, of course, just for reminding me that I hate it. :) ] I don’t understand why MS is using this approach.&#... [More]