ASP.NET 2.0 Membership
Today I’ve been spending a bit of time fiddling around with Visual Studio 2005, particularly the ASP.NET 2.0 membership functionality. When I visited 4GuysFromRolla.com to see what they had to say about it, I came across 5-part series of articles. The examples are in VB.NET, so I’ve been rewriting them in C# (my preferred .NET language) as I go along. What stood out about their information message example in part 4 of the series was that they added a label to their login page and set the text string based on the error details.
It seemed to me that there should be a property in the Login control that could be set programmatically instead of adding a label that results in two error messages for the user to look at. It didn’t take much digging before I found it. The property: FailureText.
Here’s how my revised code looks:
protected void Login1_LoginError(object sender, EventArgs e){
MembershipUser userInfo = Membership.GetUser(this.Login1.UserName);
if (userInfo == null){
//The user entered an invalid username…
SetLoginFailureText(string.Format(“No account exists with the username ‘{0}’.",this.Login1.UserName));
} else {
if (!userInfo.IsApproved){
SetLoginFailureText(string.Format(“The account with the username ‘{0}’ has not yet been approved by the site’s administrators.”, this.Login1.UserName));
} else {
if (userInfo.IsLockedOut){
SetLoginFailureText(string.Format(“The account with the username ‘{0}’ has been locked out.”, this.Login1.UserName));
}
}
}
}
private void SetLoginFailureText(string failureText){ this.Login1.FailureText = failureText; }
Effective Bug Reporting
This has been a real problem at work lately. I’ve decided to write a document to send to people who report bugs to try and stem the tide of useless “it doesn’t work” reports. I found a nice long piece on effective bug reporting by Simon Tatham here. I’ll probably use it as a reference for further reading because I envisioned something much shorter than seven pages.
Community Server 2.0 Quick Image Buttons
The blog I’m building for a client at work needed an image button to trigger searches instead of the standard link button. After my ill-advised attempts to extend CommunityServer.Controls.IButton, the consultant I’m working with recommended a far simpler solution–changing the ASP.NET LinkButton tag to enclose an HTML image tag with the border attribute set to zero (0).
If you want to use the same technique, start with this sample skin file.
A "Most Viewed Blog Posts" control for Community Server 2.0
The Code Project is one of my favorite sources for finding out how to do things on the .NET platform. Since my blog was down for a bit a couple days ago, I thought I’d put an article there on the latest bit of customization I’ve done to Community Server. If you’re interested in the article, visit this link to read it.
Adding static pages to Community Server 2.0
I was actually searching for information on how to add dynamic pages to a Community Server 2.0 installation when I came across this post. While I don’t need static pages for my current project (yet), this information probably saved me hours of unnecessary work.
Changing File Upload Limits in Community Server 2.0
I wanted to see how much effort it would take to replace this RSS feed with a CS 2.0 blog. It’s currently being generated by an old ASP application that I customized with a colleague of mine. But I kept getting errors when I tried to upload MP3 files above a certain size. A bit of googling revealed this MSDN entry and the attribute “maxRequestLength”.
Browster
I came across a story about this nifty little plug-in just this morning in MIT Technology Review. While the story was about companies trying to change the way people browse the web, Browster was the technology that interested me the most. You install a plug-in that lets you hover over a link to preview its contents instead of having to click the link. If
you want to change the way you browse the web, definitely give this a try. It could be a long while before you ever have to use the “Back” button again.
Windows Vista: The Incredible Shrinking OS
According to this article, Windows Vista is losing yet another feature. Reading further, PC-to-PC Sync doesn’t sound like much of a feature, since it only works between machines running Vista that have the same user account. But add it to the removal of WinFS, Monad scripting shell, and other bits, and the remainder is an OS that requires more hardware resources (for a prettier GUI, whoopee!) without any discernable improvement in areas like performance or functionality.
Since Vista will probably be behind what Apple users now get with Mac OS X Tiger (not to mention Leopard when that finally comes out), perhaps Microsoft should quit kidding themselves. A Windows XP Service Pack 3 release this year might help make up for Vista being so late. Then they can target the Leopard feature-set so that they’re actually releasing something competitive in 2008.
RSS Publishing
It shouldn’t be a big deal at all with apps like Community Server 2.0 or WordPress available, but budget and/or personnel constraints often conspire against us using either one. So lately, we’ve spent more time (and money, but salaries apparently don’t count) putting together custom applications to generate RSS feeds.
I always check to see if a solution to my problem already exists before building my own, so when it came time to develop the MethResources.gov RSS feed, I simply reused the example from this article by Scott Mitchell. Behind the ONDCP podcast (I did the database work, a colleague did the rest) is a classic ASP application with the most basic admin functionality.
To cut down on this sort of one-off RSS app building, I’ve been hunting around for any bits of code or fully-formed toolkits that could be reused easily. The latest interesting bit of code I came across is the ASP.NET 2.0 RSS Toolkit. It’s from a Microsoft employee, and most comments I’ve read on it have been positive. Of course, when I tried to get the samples to work, I had all kinds of problems. The solution was to create a new website project (with location = “File System”) , browse to the samples directory of the toolkit, and open the existing website. Once I did this, and added RssToolkit.dll to the GAC, all six scenarios worked perfectly. The two examples I tried from Scott Guthrie’s blog entry on the toolkit worked also.
The only things I haven’t found in this toolkit so far are support for enclosures and an easy way to syndicate a database.
Dad wants an MP3 player, but not an iPod :-(
Since I own 2 iPods (the 2GB nano that came with my new Passat, and a 20GB I bought myself), I hope to dissuade him from a non-Apple music player purchase.
He wants something to use during his workouts, and he wants a radio tuner. He’s put off by the cost Apple’s music player offerings. I haven’t looked at the Apple Store website in awhile, so I completely missed the re-pricing of the iPod shuffle. The 512MB one is just $69, while the 1GB is $99. While this doesn’t solve his desire for a radio tuner, it should meet his price.
Looking around for competitors to the iPod shuffle, I came across Dell’s DJ Ditty. It’s small and light, and manages to integrate an FM tuner. It’s $84, $15 more than the iPod shuffle of the same capacity (512MB). You’d also have to use MusicMatch Jukebox instead of iTunes.
Searching through PC Magazine revealed another option: the Samsung Yepp YP-T5. It’s an old review, but this player includes a screen, an FM tuner, and voice recording for under $60. The catch: it only has 256MB of space for music. Samsung has similarly sized (i.e. larger) offerings to the iPod shuffle that cost around $100. None of the ones I’ve seen offers more capacity than the 1GB shuffle, and some offer less capacity at a higher price.
I’ll keep hoping he goes with an iPod instead of something else. So far I’m underwhelmed by the iPod’s competition.
ASP.NET Calendar Customization
My latest assignment is to help redesign this website into a true blog for the office of the drug czar. We’re using Community Server 2.0, and one of our requirements is to customize the calendar. Since the CS 2.0 calendar is a wrapper around the stock .NET framework one, I put together a Word document to explain the customization process to the graphic designers who are actually responsible for the look-and-feel of the calendar. My hope is that they’ll understand it well enough to reduce my workload when it comes time to implement this.
The document applies pretty well to calendar customization in general for ASP.NET 1.1 projects.
I created an RTF version and an HTML version of the content as well.
A general theory of design
“Design consists of creating things for clients who may not know what they want, until they see what you’ve done, then they know exactly what they want, but it’s not what you did.” – Brian Sooy Read Mr. Sooy’s entire blog post. I’m not a designer, but having spent most of the past 10 years working with them to build database-driven websites and applications, I definitely agree with him. My most recent project (an extranet for the nation’s AMBER Alert coordinators) didn’t launch until 6 months after its originally scheduled launch date in large part because of the client’s uncertainty over what they wanted.
Community Server 2.0 Patching
Telligent sent out an e-mail last Friday afternoon about a critical security patch. These were the patch instructions:
Directions for installing the patch:These are the contents of the readme.txt file:
- Download the .zip file here:
- Community Server 1.1: [communityserver.org/files/fol...](http://communityserver.org/files/folders/archived_cs_releases/entry532297.aspx)
- Community Server 2.0, ASP.NET 1.1: [communityserver.org/files/fol...](http://communityserver.org/files/folders/releases/entry532260.aspx)
- Community Server 2.0, ASP.NET 2.0: [communityserver.org/files/fol...](http://communityserver.org/files/folders/releases/entry532293.aspx)
- Unzip the file(s) and extract them to a location on your computer
- Follow the directions in the readme for installing the patch on your Community Server 2.0 server(s)
Steps for installing the Community Server 2.0 SP1 Patch.I wish the readme file had said exactly where the updated source files go. I don't like the idea of having to hunt around files to replace when the patch has to do with security. So here's what the readme file should include:1. Make a copy of the CommunityServer.Components.dll found in the bin folder of your web site. 2. Replace the existing CommunityServer.Components.dll with the new one you just downloaded and unzipped.
If you have questions or problems, please email support@telligent.com
We have also included the updated source files. If you have modified any of the code in the Community Server Components project you will need to apply these fixes and redeploy your assemblies.
ComponentsHttpModuleCSHttpModule.csTelligent has an announcements blog with a post about this security patch.ComponentsComponentsHtmlScrubber.cs
ComponentsComponentsTransforms.cs
Paging in Microsoft SQL Server stored procedures
Today I found out that an old boss of mine at Ciena Corporation has a blog (thanks to Plaxo). I learned a lot about ASP.NET, C#, and Plumtree through the work he assigned to me. From looking at the posts he’s got in there so far, if you’re looking to overclock a PC or find out more about Vista, it’s worth checking out. An older post of his has a good example of how to implement paging in a SQL Server stored procedure.
IntelliSense for SQL Query Analyzer
Red Gate Software is giving away a tool called SQL Prompt until September 1, 2006. If you work with SQL Server at all, definitely visit Red Gate and grab this.
Amazon "1-Click" Patent Challenge
According to this article, Amazon’s patent is being reviewed because it looks like the U.S. Patent & Trademark Office granted a similar one 18 months before Amazon’s filing. It will be interesting to see what fallout there would be from a decision invalidating Amazon’s patent.
That aside, this brief story does a nice job of pointing out how profoundly broken the patent system is. The prior patent wasn’t found by a USPTO employee, but an actor from New Zealand who was angry about a slow book delivery and wanted to get back at Amazon. If Amazon hadn’t made one of their customers upset, who knows if this would have ever been found. The patent review will probably revisit these requirements:
- is 1-click new
- is 1-click useful
- is 1-click nonobvious
Stored Procedures vs. Ad-hoc SQL
I saw this insightful article on the subject in a “most popular articles” list. The author, Douglas Reilly, acknowledges at the beginning of the article that he uses stored procedures virtually all the time, but still does a great job of describing the pros and cons of each approach.
The most useful thing the article taught me was that as of version 7, SQL Server keeps execution plans for all statements, not just stored procedures. This reduces the advantage of stored procedures for basic CRUD (create, read, update, delete) operations substantially. I’ve certainly touted the superior performance argument in comparing stored procedures to ad-hoc SQL before, so I’m glad I learned the real deal now. That said, I still hold a bias in favor of stored procedures. Once upon a time, I worked for Sybase Professional Services as a DBA, and they were definitely pro-stored procedure. Nearly every shop I’ve worked in since then has been similarly inclined. Anytime an employer has used ad-hoc SQL, it’s been absolute murder to maintain. In my experience, the maintenance advantage of stored procedures over ad-hoc SQL is substantial, not slight (as Reilly concludes).
One issue the article doesn’t bring up that might be interesting is source code control for stored procedures and other database elements (views, user-defined functions, etc). While SQL Server does have backup and restore, it’s not nearly as granular or convenient as the check-in/check-out model of today’s source code control systems. On my projects, I tend to generate a script with just the stored procedures in it and store that in SourceSafe. I’d certainly like a better solution, but haven’t found one yet. I’m curious to see what SQL Server 2005 is like, since it will allow you to write stored procedures in C# or VB.NET.
Apple's business model beating Microsoft's
So says Walt Mossberg, the man with the job I envy most in technology.
I agree with what he says for the most part on the advantages of the end-to-end model versus the component model. One thing I would say that’s slightly different is that Apple is winning not merely because of the tight linkages, but because of the quality of the end product, and their huge market share.
Having lost what Mossberg describes as “the first war” in the personal computing space, Apple took a look at the MP3 player market and delivered a product significantly ahead of the competition in quality and ease of use. Even when connected to a PC (as I did with my first iPod), using MusicMatch for the music software, I liked the experience better than other players I’d considered. Once iTunes came to the PC, it made things even easier.
Part of what helped Apple get its current marketshare in the digital music market is their refusal to inflict the subscription model on their customers. They understood that people want to own music instead of renting it and delivered just that. Between that, their great per-track price point, and the minimum necessary DRM, there are plenty of reasons to choose Apple over the competition.
Removing time from a datetime field in SQL
I’ve got a small project at work that required me to use the date, but not the time in a datetime field for retrieval of certain rows from a table in SQL Server 2000. A bit of Googling revealed a document titled “Remove seconds from datetime SQL”. The title isn’t quite right, as the author’s query removes hours and minutes too, but the result turned out to be just what I wanted.
The query: SELECT Cast(Convert(varchar, GetDate(),105) as datetime) I ended up using code 101 instead of 105 to get my query working, but that was it.
ASP.NET Configuration File Handling
One of things I like the least about working with multiple development, QA, and production environments is messing around with configuration files to make sure the different versions point at the right databases. Add the use of the Enterprise Library, and there are even more files to manage.
In my last year at Ciena, I worked in a group where they’d put together some code that detected what environment it was in (development, QA, or production) and retrieved the correct settings from web.config. It was similar to the solution Mike Gunderloy describes in this article on ASP.NET 2.0 productivity.
When I was poking around for more information on config file handling, I came across another article that references Gunderloy’s that talks about a file attribute for the appSettings tag. I hadn’t come across the existence of that attribute anywhere else before. I’ll definitely use this on my next project.
Finally, this article provides another option for dealing with configuration files in multiple environments. The code and examples are well-explained. My group at Lockheed Martin should integrate something like this into the custom library we’ve been building.