March 2005 - Posts
I've recently been re-visiting some friendly URL support that I have in a CMS that I wrote a little while back. The way the CMS currently handles friendly URL's is by doing a wild-card mapping in IIS. This causes everything to be processed by the asp.net pipeline. Then within my web.config I map various extensions to the proper page handler. This includes mapping image files (.jpg, .gif) as well as stylesheets and etc to the StaticFileHandler. The last handler I have setup maps all remaining extensions to a custom PageHandlerFactory class that performs the magic of figuring out what pages to server for a given url. Once the template (.aspx) associated with a URL is determined I use PageParger.GetCompiledPageInstance to get the page instance and complete the processing of the request.
The above method has worked reasonable well, however, I have seen a bunch of quirks on different systems and also had some issues getting it working on virtual websites on my development machine (WinXP) unless the CMS managed site was setup as localhost. With all the other projects I have it's a pain to switch where localhost is pointing even with some of the nice tools for managing multiple web sites in WinXP.
The last couple days I've been revisiting this in search of a better solution. As part of the process I've investigated using an HTTP Module, using a custom 404 page, and a bunch of other methods that would flat out just not work. The HttpModule methods involves setting up a event handler for the BeginRequest method that looks up the correct location for a URL and then does a Context.RewritePath. Although this works it doesn't come without it's own quirks. The main issue with this method is that if you have a post back on your page the nice friendly URL that you're showing users gets lost and you're big nasty URL that you've been trying to hide rears it's ugly head for all visitors of your site to see. Jesse posted on a way to get around this which appears to work pretty well. Apparently the process of rewriting the path causes problems with ViewState as well. Late last night I began running into all sorts of issues with Invalid ViewState after implementing the HttpModule and form action hack that Jesse provided.
In short the current support for friendly url's isn't where it needs to be. All the current methods for rewriting URL's have quirks and issues that leave us with a bunch of working, but, far from ideal solutions to the problem. Here's hoping to some better support in upcoming versions!
I’m trying to get friendly url’s all setup on an app using RewritePath but I keep having problems with ViewState getting corrupted. I can’t seem to find anything online, anyone have any ideas on how to resolve this?
I recently came across a
paper written by several ThoughWorkers on the ObjectMother pattern. The
ObjectMother pattern seeks to make the creation of objects for testing simpler by reducing code duplication, ensuring fresh objects are created for tests, and ensuring tests always clean up after themselves. Although I just recently came across this pattern I've been using a variation of it on many of my projects over the last year or so. Consolidating my individual factory methods for creating test objects (that sometimes appear within a Test Fixture) into a ObjectMother object is something that I'll be looking to try on a project soon.
I saw the offer for free mini macs online a couple months back but I figured I'd hold off on trying it until I heard of some people who actually received their Mini Mac. Well I've heard of a couple people receiving them so I decided to join in on the fun.
Go get your FREE MINI MAC!

UPDATE: I ended up signing up for BlockBuster Online. It turns out the wife had been interested in this anyway so it worked out. Oh, an no spam so far….
UPDATE #2: At this rate I should have my Mac Mini in about 100 years. I've had a few peeps register but no-one has actually completed an offer. :-(
Darrell has an excellent post on "How to fix the software development industry". He mentions the often quoted statement that great programmers are 10x more productive yet they are not paid for this tremendous value. I won't quote Darrell's entire article just go read it, he provides a great analysis of the situation we all find ourselves in.
Brian Button has an excellent post about how he defeated “Programmer’s Block” through test driven development (TDD). I’ve had a similar experience many times. Having an empty test class can sometimes be very daunting. What test should I start with, what do I even want this class to do? How can I ensure I design it properly? Who is going to use it? What are they going to want to do that I won’t think of? What classes should I build around this class to make the API as simple as possible?
When I start feeling “programmer block” I find that writing the simplest test I can think of is a good way to get going. It’s amazing that a little green bar can give you the confidence needed to get to the next test, but I’ve found that it often does.
Lots of good feedback on the Contractor vs Consultant article I posted a couple days ago.
I think the important thing to realize is that as an independent you are what you make yourself. If you want to be someone that comes in and cranks out code, doesn’t give any opinions on things, and is a “body” then that’s what you’ll be. If on the other hand you want to be someone who expresses their opinions, and makes themselves someone that others come to for advice then you can do that as well. Whatever it is I think James Avery makes a good point, who cares if you’re called a “consultant” or a “contractor”, the labels don’t mean a thing. You are what you make yourself, regardless of what people try and label you as.
Sometimes lists are helpful….
– Using DDD on a real life project
– Dependency Injection, what type is right for you?
– AspMap & GIS
– TDD’ing the GUI….or not so much
A colleague at work recently purchased
Head First Design Patterns. After spending a couple nights reading it he recommended it to some others in the department. Today I saw that it won a Jolt award which is usually a very good indicator of a book that you’d want to spend some time reading. I ordered a copy after the initial recommendation so I’m looking forward checking it out. Design Pattern books are generally pretty dry which I’m told is not an issue with Head First. Hopefully after spending some time with it I’ll remember to post a review to let you know if it’s worth picking up.
I recently came across "Consulting vs. Contracting" which I thought provided some interesting opinions on being a consultant vs. being a contractor. I've worked in a pseudo-consulting shop for the past 5 years and think in general the opinions of the author of the post are accurate. I wonder how many "contractors" feel the same way though. As I've mentioned a couple times on this blog I often wonder if I'd like the "independent life." There are definitely some appealing things about it, but of course there are also some negatives. The other thing I wonder is how many people who "go independent" do so as a contractor vs as a consultant. I would think it'd be much easier to start as a contractor, is it? How many "independents" would consider themselves a "contractor", ok, now how many would consider themselves a "consultant"?
I came across a post from Richard Hundhausen that listed out all the .NET O/R Mappers that are currently out there. I think we need to consolidate! How is somebody supposed to choose from that many choices.
I have a homegrown O/R Mapper that I've been using for a while that I've been considering ditching for something like NHibernate. Having so many choices to pick from makes deciding which one to use should I ditch my own a bit more painful. Is the market for O/R Mappers big enough for that many competitors? I vote for some consolidation, oh and if you're thinking about writing your own commercial O/R Mapper, please don't. **
** If on the other hand you're looking for a fun project...go for it, writing an O/R Mapper brings up all kinds of interesting challenges that you might not have to think about on "boring old business apps" ;-)
The more information I see on C-Omega the more intersted in it I get. Check out Rick Byers recent post on “Comparing a simple select statement in C-omega vs. ADO.NET”
rows = select * from DB.Employees where City == city;
foreach( row in rows ) {
string name = row.LastName.Value;
int id = row.EmployeeID.Value;
Console.WriteLine( id.ToString() + ": " + name);
}
Jason Alexander has a nice set of
CodeSmith templates for documenting a database. If you haven't checked them out, you should!
I'm in the process of setting up a load testing environment for my current app. As I'm moving my database over via T-SQL scripts and command files from my database project I've been running into really strange issues. It appears that some of our scripts don't have the same casing as the parameters and/or column names do and as I'm running my scripts on the database server (Windows 2003) my scripts are failing because of the mis-match. As an example I had a stored procedure that was doing a join to another table which had an alias set to "D", however, below in the query it referred to this alias as "d". When running the command file I was getting an error saying that the "d" alias was invalid. I've run these scripts hundreds of times on other databases and never received this error, what gives? Why would SQL Server start caring about case sensitivity in column names, aliases, and parameters?
We recently had some discussions regarding our build server setup and how we need to alter some web.config items when doing release builds. One of the primary things that we wanted to ensure is that the compilation of asp.net files is not set to debug, which is the default.
<system.web>
<compilation defaultLanguage="c#" debug="false"/>
</system.web>
More Info:
Steve Maine has a post about implementing validation in .NET using attributes. I agree that adding validation declaratively is a positive thing. I also think he hits the nail on the head when he mentions that not everything should be done via attributes. There are still many times when diving into writing some validation in you business/validation components makes the most sense. As with anything finding the right balance between the two is key. Rather then trying to do everything with a given technology it’s important that we find the just the right mix.
Below you can find some of m previous entries on the topic:
I’ve been hacking around with a lot of search related technology recently. We have a project at my gig where we need to implement a site wide search for a reasonable sized website. We investigated a bunch of different products and technologies during the process.
Before this most recent search bonanza I was doing a decent amount of work with DotLucene. For those of you unfamiliar with DotLucene I recommend you check it out. It’s an open source port of the Apache Jakarta Lucene project. DotLuene is a “powerful open source search engine for .NET applications”. It’s a very powerful tool which I’d highly recommend to those looking to implement search on your site, or within your application. By combining DotLucene with a .NET wrapper around Indexing Services IFilter components you can get indexing of not only HTML content but also Microsoft Office, PDF, and any other file type that has a IFilter available.
The other project which I’ve come across is Nutch, which is an open source web crawler that creates indexes of websites. It uses Lucene behind the scenes and I believe has some seriously large indexes being created with it (can’t remember where I saw mention of this). Anyway all of this has sparked my interest in the technology behind search. I’m planning on spending some more time in the coming weeks and months playing with DotLucene, overviewing the Nutch code base, and thinking about what might come of it all.
My current project is using Reporting Services as the reporting engine for our application. The application involves brining in lots of data from an external system and reporting on that data in interesting ways. A lot of our reports are “pivot table’esque”. To implement these reports we’re using “matrix” reports within Reporting Services. Enough background on to the rants….
Rant #1 – Did anyone think about how reports would be implemented in a web environment?
One of our early frustrations was with linking reports that are displayed via the Report Viewer server control. For those of you unfamiliar with the Report Viewer server control, it renders an i-frame within your HTML with the report displayed within the i-frame. Unfortuantly the HTML that Reporting Services renders doesn’t allow you to use the Report Viewer as the container for sub-reports when you drill down. Reporting Services generates links with target tags on the anchor elements which causes the “drilldown” to the sub-report to launch in a new window. There are some workarounds for this such as using the rs:ReplacementRoot, but none of them are very clean. It seems like figuring out some use-cases for how people would use reports within web applications would have forced the implementation to be much better. Perhaps those use-cases were never developed?
We ended up using javascript: to get the desired behavior. Luckily SP1 provided support…
Rant #2 – Can we get a little flexibility with our Matrix reports?
As I mentioned above we have a bunch of “matrix” reports within our application. Compared to the table layout the matrix layout is very restrictive. It’s difficult to add on your own columns to the right of the matrix, and customization capabilities of the layout doesn’t provide the flexibility that’s necessary for the vast majority of reports that we wanted to create. The flexibility of the table layout needs to be combined with the matrix layout.
In order to get our reports laid out the way we wanted we had to use sub-reports. Our matrix was shown in a sub-report on the left and another sub-report was displayed on the right with our “custom columns”. The formatting and alignment of the sub-reports has proven to be a bit painful.
Rant #3 – Exporting to Excel doesn’t include sub-reports?!?!?!
To get around the limitations of the matrix report we ended up having our reports laid out using sub-reports. This allowed us to get all the data on the report that we needed and also get the benefits of the “matrix”. I imagine that most reports developed using Reporting Services make use of sub-reports. With this in mind, why in the world would the Export to Excel feature not support sub-reports? One of the advantages of going with a reporting package such as Reporting Services is that it supports exporting data to a variety of formats…well at least we assumed. Without support for exporting sub-reports the “export to excel” feature within Reporting Services is completely useless. What’s even better is that as far as I can tell this isn’t something that will ever be supported for SQL Server 2000. I guess by making Reporting Services crappy on SQL Server 2000 there is a hope that people will just move to SQL Server 2005. I should probably go get started on my custom export to excel feature :-(
No solution for this item so far, I’m hoping to uncover some miracle solution so I don’t have to write the export to excel feature myself. The ability to export to other formats (excel specifically) was one of the major selling points for us. What a bust…
If you're currently using
Lucene for searching on your .NET based site I recommend you checkout
XmlIndexer, written by Edd Dumbill. It's a very cool add-on that makes indexing of Xml documents as easy as creating a mapping file for the elements within your document. Very cool.
I while ago I was looking for some good ASP.NET Content Management Systems and couldn’t find any. It appears that since then a number have come onto the scene. A few of my front-runners are:
What CMS do you like best? Comments?
This is going to be a life saver when I go to deploy my current project.
Reporting Services Scripter is a .NET Windows Forms application that enables scripting of all Microsoft SQL Server Reporting Services catalog items to aid in transferring them from one server to another. It can also be used to easily move items on mass from one Reporting Services folder to another on the same server. Depending on the scripting options chosen, Reporting Services Scripter can also transfer all catalog item properties such as Descriptions, History options, Execution options (including report specific and shared schedules) and server side report parameters.
Klaus Aschenbrenner has a
post today where he points out that one of his use case's where he had to update 10,000 records ended up being much faster when using T-SQL. I think he brings up an important point. O/R Mapper's are a great time saver, I use them on most of the work I do these days, however, I still use T-SQL as well. Bulk updating of data is usually not a strength of an O/R Mapper so T-SQL is the better approach.
LLBLGen Pro and
WilsonORMapper already have features that allow the updating of 10,000 records via their "mapper" to be converted into a single query, hopefully the makers of other O/R Mappers will follow. Until they do make sure you know how your O/R Mapper is working behind the scenes so you know whether performing an action using you're mapper of choice or via T-SQL is the way to go!
Mike Roberts has put together a great set of posts (now consolidated into one) regarding How to setup a .NET Development tree.
A few months ago I developed a content management system (CMS) for a client. I've had several other clients use the CMS to help them manage their website and overall the feedback has been very positive. Although the current UI is decent I'm looking to spice it up and make it more usable. So if you, or someone you know is a UI guru drop me a line via my contact form. Please include some samples, as well as your hourly rate. If you think you could attack it as a "project" feel free to quote that as well. As a deliverable I'll be looking for all original design material as well as a basic mockup in CSS + HTML.
Cheers,
Steve
Peter asks a few questions regarding the unit tests in Enterprise Library:
- Are the unit tests in Enterprise Library 1.0 valuable to you?
Yes, when I was reviewing the code I looked at it along side the unit tests so I could get a feel for how the code was intended to be used. I also did a overview of the unit tests in general to see how the EntLib team approached testing. I was particularly interested to find some of the tests *gasp* hitting the database. So many people advocate never hitting the database with unit tests which is something I haven't bought into. There are certain things that should hit the database when unit testing. The unit tests in EntLib that hit the database are a perfect example of when it does make sense.
- What was good? What was bad?
Good was the ability to see how the components could be used from the unit tests, good was the ability to see another teams approach to testing, good was seeing how you did unit testing against the database, good was having a set of unit tests to re-run after making changes (if I actually had).
Bad was....um....well....can their be anything bad with having unit tests? If I had spent more time with EntLib I'm sure I'd have something for this but I haven't so I don't 
- Did you run them when you got the code?
Yes
- Have you referred to them while exploring the EntLib code?
Yes
- If you’ve made changes to the EntLib code, did you update the unit tests? If not, why not?
Didn't make any changes, but if I had I would have updated the unit tests.