BusinessRx Community

Dedicated to the advancement of software, technology and the people who devote their lives to it.

Welcome to BusinessRx Community Sign in | Join | Help
in Search

BusinessRx Reading List

These blog entries are written by industry experts and leaders. We consider this content to be a good read for any software developer or web technologist.

September 2009 - Posts

  • Lower Case URLs and ASP.NET MVC

    It sounds like an easy question -

    “How do I make my ASP.NET MVC application generate lowercase URLs?”

    Using lowercase URLs is an SEO best practice, and something you can easily enforce with a tool like URLRewrite. But, the action links generated by the MVC framework generally contain upper case letters (since controller and action names are generally PascalCased).

    First, let me say that Graham O’Neale and Nick Berardi have already solved this problem in a foolproof manner. What I am trying below is a little bit easier, but does have one problem if you rely on route names. We always specify route names when using the MapRoute extension methods, but in actuality these names are rarely used to generate URLs in an MVC application. Instead, we generate URLs from controller and action parameters.

    Nick and Graham both create a class derived from Route to lowercase the URLs returned by GetVirtualPath. Unfortunately, this means you can’t use the built-in MapRoute extensions method provided by MVC. For various reasons I wanted an approach that could somehow work with the built-in MapRoute methods. In looking for a solution I realized:

    • You can’t intercept or override the existing MapRoute extension methods (of course)
    • You can’t derive from RouteCollection and override the Add method (because it’s not virtual)

    What I did come up with is to use a route decorator:

    public class LowercasingRoute : RouteBase
    {
        public LowercasingRoute(RouteBase routeToWrap)
        {
            _inner = routeToWrap;
        }
    
        public override RouteData GetRouteData(HttpContextBase httpContext)
        {
            return _inner.GetRouteData(httpContext);
        }
    
        public override VirtualPathData GetVirtualPath(...)
        {
            var result = _inner.GetVirtualPath(context, values);
            if (result != null && result.VirtualPath != null)
            {
                result.VirtualPath = 
                    result.VirtualPath.ToLowerInvariant();
            }
            return result;
        }
        RouteBase _inner;
    }

    Then, after all the route registration code is finished, wrap the existing routes in the routing table with the LowercasingRoute.

    private void DecorateRoutes(RouteCollection routeCollection)
    {
        for (int i = 0; i < routeCollection.Count; i++)
        {
            routeCollectionIdea = new LowercasingRoute(routeCollectionIdea);
        }
    }
    

    Unfortunately, I lose all the route names using this approach. The RouteCollection class takes the route name we pass in MapRoute and stores it in a private dictionary and you never see it again. This isn’t an issue as most MVC applications will never use a route name to generate a URL, but it makes me nervous enough to wonder what to do next.

    • Give up and use custom MapRoute extension methods?
    • Use reflection to read the dictionary of route names?
    • Fork the source?
    • Open a request on Connect?

    What do you think?

  • Death to .NET Events

    When .NET arrived on the scene it promoted the use of events and delegates to decouple code. Chris Sells had one of the best early stories on how it all works (.NET Delegates:A C# Bedtime Story)*:

    Once upon a time, in a strange land south of here, there was a worker named Peter. He was a diligent worker who would readily accept requests from his boss. However, his boss was a mean, untrusting man who insisted on steady progress reports. Since Peter did not want his boss standing in his office looking over his shoulder, Peter promised to notify his boss whenever his work progressed.

    For a few years I think we were all infatuated with events. We used them everywhere from the web to the desktop, and even in between. Looking around, you have to wonder if we went down the wrong road.

     roadsign

    Consider the people who …

    I’m thinking one day soon we will compare writing explicit event code to manual memory management.** Both will be low level details we don’t see in our everyday code.

    If so, this will be quite a change from just a few years ago.

    --

    (*) The start of the story should sound familiar to anyone who worked with COM’s IConnectionPoint, which almost qualifies the story for an award in the horror category.

    (**) If this means I never see the INotifyPropertyChanged interface in anyone’s code ever again, then I’ll welcome the new event overlords with open arms.

  • SEO with ASP.NET 4 and Visual Studio 2010

    My latest article for MSDN Magazine appeared online and in print a few weeks ago. This article is about search engine optimization with the latest and soon-to-be released tools.

    It wasn’t so long ago that SEO experts would lambast the .NET platform as poor choice of technology for SEO work, but much has changed just in the last year. While working on the article I exchanged some emails with Carlos Aguilar Mares, who sold me on features in the SEO Toolkit and the URL Rewrite extensions for IIS. The SEO toolkit will crawl your site and warn you about things the search engines don’t like to see - like bad redirects, missing ALT attributes, broken hyperlinks, and multiple canonical formats. You can use the toolkit to manage robots and sitemap files, and even find malware on your site. The URL Rewrite module can give you optimized and friendly URLs without giving up the performance benefits of kernel mode caching.

    Things get even better next year with some of the features the ASP.NET and Visual Studio teams have in store. Read the article for more details.

  • Brainsick Patterns &#8212; No Code Relation &raquo; Blog Archive &raquo; C# Dispose

    Pingback from  Brainsick Patterns &#8212; No Code Relation  &raquo; Blog Archive   &raquo; C# Dispose

  • PROBLEM: CSS Styles No Longer Apply For Anonymous Users

    I teach two ASP.NET courses as the University of California - San Diego Extension. In the second course students use forms-based authentication and ASP.NET's membership framework to create a web application that supports user accounts. Invariably, at least one student bumps into the following scenario:

    • The website's formatting and layout is defined via CSS rules, which are located in one or more .css files.
    • The URL authorization settings have configured such that web pages on the site can only be accessed by authenticated users. That is, the <authorization> section in the Web.config file in the root folder contains the following markup:

      <authorization>
          <deny users="?" />
      </authorization>


      Some students lock down the entire site to authenticated users only. Others may have one or more <location> elements that open up access to specific pages to anonymous users, or have a separate folder with its own <authorization> settings that allow anonymous access to the pages within.
    • The website is served using the ASP.NET Development Server, which is the lightweight web server that ships with Visual Studio and is launched when you run a file system-based web application from the IDE.

    When the above conditions hold, students find that when visiting their site those CSS formatting and layout rules defined in the .css file(s) are not applied for anonymous visitors. For example, when visiting the login page, the website's colors and fonts and layouts defined in the .css file(s) are not in effect. However, once the visitor signs into the site, the CSS rules take effect.

    What's going on here?

    The reason the CSS rules are not applied when the site is visited by an anonymous user is because of how the ASP.NET Development Server handles web requests. In a nutshell, every single request that arrives to the ASP.NET Development Server - be it for an ASP.NET page or a CSS file - is dispatched to the ASP.NET engine for processing. Consequently, the URL authorization rules defined in Web.config apply to the CSS files as well as the ASP.NET pages. So when an anonymous user visits, the page includes the <link> elements to the CSS files and the browser requests them, but the web server responds with a redirect response to the login page. As a result, the browser does not get the CSS content and that's why CSS rules do not apply for anonymous users (and why they start applying once the visitor signs in).

    The simplest workaround is to configure the URL authorization rules to allow anonymous users to access the CSS files. If you have the CSS files in a separate folder (such as /Styles), then you can simply add a Web.config file to that folder with the following <authorization> settings:

    <authorization>
        <allow users="*" />
    </authorization>

    If the CSS files are in the root folder, then you will need to add a <location> element in the root folder's Web.config file for each CSS file and use the above markup to permit anonymous users to access those files. For more on using the <location> element, refer to location Element (ASP.NET Settings Schema).

    Finally, keep in mind that the behavior described here only occurs when the web server dispatches requests for CSS files to the ASP.NET engine. As aforementioned, this is the behavior of the ASP.NET Development Server; however, this is not the default behavior of IIS. By default, IIS handles request for static content itself, meaning that ASP.NET's URL authorization rules will not apply to CSS files, JavaScript files, images, ZIP files, and so on, although it is possible to instruct IIS 7 to integrate it's security checks with ASP.NET's configuration via the Integrated Pipeline mode. See Apply ASP.NET Authentication and Authorization Rules to Static Content with IIS 7.0's Integrated Pipeline Feature for more information.

  • Victory In Software Development

    I wrote the following prose in preparation for my fireside keynote at Concept Camp 2009. Concept Camp arrived at a time when I was asking questions about the software I’ve created over the years. I was wondering if the software I’ve created is truly successful, and how you measure success in software development.

    ConceptCamp Campfire  

    I’ve written commercial software for many companies over the years. Some of the best software I’ve created was for companies that are now out of business. Was the software a failure? Some of the worst software I’ve created, as a developer working alone and just out of school, is still running inside laboratory instruments around the world. Is that software a success?

    Athletes declare victory and defeat using scoreboards and finish lines, but success – real success, isn’t easy to measure in software development, or in other lines of work. As an example, let me tell you the story of two men working as army generals, and you try to decide which one achieved victory.

    A Tale of Two Generals

    Concept Camp 2009 took place just outside the town of Williamsport, Maryland, which is near my hometown of Hagerstown, MD. Since I grew up in this area I had no choice but to learn about the local history, and there is no shortage of history in the area. For instance, Williamsport, holding a prime location along the Potomac River, was one considered by George Washington as the site for our nation’s capital.

    Not far from Williamsport is the town of Sharpsburg. Its 700 residents live next to the Antietam Battlefield – one of the most famous battlefields on American soil. 147 years before Concept Camp, this area was full of soldiers fighting the American Civil War. The general leading the Confederate army from the south was General Robert E. Lee. The General leading the Union army from the north was General George B. McClellan. Both generals were graduates of West Point, but the two applied vastly different strategies in battle.

    Autumn sky over Antietam battlefield

    The Setup

    General Lee assumed control of the Confederate army in the spring of 1862. This was during a time when many felt the war would be over quickly. The Union had already invaded the south and the army was sitting outside the capital city of Richmond, VA. Lee quickly won a series of battles, however, and pushed the Union army away. Those battles ended the hope for a quick end to the war.

    The situation was beginning to worry President Abraham Lincoln. European powers like Britain and France were watching the rebel army effectively defend its territory, and they were thinking of supporting the south’s claim for sovereignty. Meanwhile, mid-term congressional elections were coming up in November, and if the northern voters perceived the war as going badly, their voting power could end Lincoln’s plan to reunite the country.

    Against this backdrop, General Lee saw an opportunity for great military and political gains. In early September, he led his army north across the Potomac River. It was the Confederate army’s first steps on Union soil.

    The Battle & Aftermath

    General McClellan chased Lee’s army until they met outside of Sharpsburg by the Antietam Creek. The ensuing battle on September 17, 1862 was horrific. It is still the bloodiest day in American history with 23,000 casualties. You can read about the terrible fighting around Miller’s cornfield, Bloody Lane, and Burnside’s bridge in books like “Antietam - A Soldier’s Battle” by John Priest (my history teacher in school).

    McClellan’s army left 30% of Lee’s army dead or wounded. Because of the casualties, Lee had to withdraw his army and return south to Virginia. President Abraham Lincoln took this opportunity to issue the first Emancipation Proclamation on September 22nd. The Proclamation meant the war was no longer just a war between states, but a war to end slavery. The higher cause boosted the morale of the Union soldiers and bolstered support for the war from voters. Overseas, the Proclamation forced European powers to reconsider support for the rebel states, as they didn’t want the world to perceive their policies as supporting a slave nation.

    Doesn’t this sound like a decisive victory for McClellan and the Union?

    Cornfield Ave Antietam

    The Analysis

    Of course, I didn’t give you all the information you needed to know about the battle. I didn’t mention that McClellan’s army outnumbered Lee’s army almost 2:1 (90,000 men to 50,000 men). I didn’t mention that McClellan kept half his men in reserve – they never fired a shot. I also didn’t mention that McClellan split up his attacks into three separate assaults, giving Lee time to shift and reorganize his defenses. And I didn’t mention how vulnerable Lee’s position was with his back to the Potomac River.

    Finally, I didn’t mention that President Lincoln, unhappy with McClellan’s performance, removed the general of his command not long after the battle.

    Most experts believe McClellan had the opportunity and resources to eliminate Lee’s army and put an end to the war. Instead, the civil war continued for three more years.

    Victory

    It’s difficult to draw analogies between war and software development. One is a bloody endeavor that kills while leaving physical and mental scars. Another is a profession that involves keyboards and cubicles under fluorescent lighting. Nevertheless, I think there is something we can learn about victory from the Battle at Antietam. Achieving victory doesn't mean we've achieved our full potential.

    Also, we already know that victory is hard to define. Shipping a product isn’t a reason to declare victory, particularly if the product falls apart after 1 month. We can’t declare victory based on the number of lines of code we’ve written, or the number of features we’ve shipped. Having too much code or too many features can  lead to defeat. We can’t declare victory based on the number of unit tests we have, or code coverage statistics. We can’t declare victory by pushing cards across a Kanban or moving a line down a burn down chart.

    kanban

    All of the things I’ve mentioned are indicators of success, but even if we look at them collectively we’d still be missing the judgment of the people who use our software. Does it have the right features? Is it fast enough? Is it friendly? Does it work without unnecessary surprises? Did it reach on time? Did it cost too much?

    Customers, clients, consumers, and users all have a considerable say in our success and failure, and we can’t ask their opinion using only a single point in time, just like we can’t declare the winner of a 100 meter dash by observing runners at the 50 meter mark. Most applications need to evolve over the course of years, and we can only achieve victory if we continue to grow the application.

    Returning to a military theme, there is the type of victory known as a pyrrhic victory. A pyrrhic victory is what happens when you are decidedly victorious in a single battle, but paid such a heavy price to win that you are in a position to lose the war. Not everyone realizes that software development is a marathon, and shortcuts often lead to pyrrhic victories. The application ships, but it’s an un-maintainable collection of shortsighted hacks that will fail to evolve with the user’s needs in the future.

    User Eccentric

    Since users have a considerable vote in our quest for success, having them invested in our software project is a great idea. The good news is that software development is making concerted efforts to move the user closer to the center of our development activities.

    We started by changing our methodologies. We realized that a waterfall process, where the user tells us in detail what they want, and then we hide in offices for 24 months while building it, results in defeat for everyone involved. We started to adopt agile methods that embrace change and require everyday participation from the users.

    We also started moving users closer to our code. Doman driven design encourages the use of a ubiquitous language that the developer and the business expert share, and the language influences the names of our abstractions. We strive to write acceptance tests using natural languages a customer can understand. Everyone wants a domain specific language that a business expert can comprehend.

    We’ve moved our users closer to what we do, but software development is still not centered around the user. Developers sit in the center of software development as the sun sits in the center of our solar system. We use our heavy mass of technology to distort light, space, and time to our needs. We tell the user what can and can’t be done. We’ve trained them to come to us and ask us what’s possible, instead of envisioning their own possibilities.

    Like General McClellan in the Battle of Antietam, we aren’t reaching our full potential.

    Risk and Reward

    General McClellan didn’t fight to win the Battle of Antietam – he fought not to lose. He was cautious. He was pessimistic. He didn’t pursue Lee’s weary army as they hobbled back into Virginia, though he had fresh regiments of soldiers available. McClellan saw only risks, and not the opportunities.

    Software developers are obsessed with mitigating risk. All the indicators of success we talked about earlier- deadlines, code coverage, unit tests, burn down charts – these are all in place to mitigate risk. We also mitigate risk with compilers, coding standards, source control systems, patterns, practices, daily stand up meetings, continuous integration builds, and more.

    risk

    Avoiding disaster in software development requires an obsessive-compulsive approach to risk management. We focus on risk instead of potential.

    Our focus means we don’t fight to win in software development. We fight not to lose.

    Once a customer asked me how I could automatically populate one of the screens in her application with information held inside a database of manuscripts. I immediately saw the risk in matching data to the right fields based on the context of the screen. I’d need a way to search and index the correct pieces of information. I’d need some fuzzy logic to interpret the meaning of the data. There would be some advanced algorithms needed to transform and pick apart the appropriate information.

    I wasn’t thinking of the software’s potential. I wasn’t thinking about how this feature could transform the lives of the people who used the software. I saw only the risks. I surrendered to fear.

    Courage Conquers Fear

    Kent Beck listed courage as one of the primary values to embrace in his Extreme Programming book. We’ve made significant advances in embracing many of the other values listed in the book. We practice test-driven development while reciting the Single Responsibility Principle in homage to the value of simplicity. We hold daily stand up meetings and apply continuous integration to promote the value of feedback.

    But courage?

    It’s difficult to find a pattern or a process that helps us practice courage on a daily basis.

    skydive

    How many times have you seen a software team talk a customer out of a feature because it might require something different, or unknown?

    • Trying a technology outside of company “rules” (like using an open source library)
    • Using a “non-standard” technology (like a non-relational database)
    • Trying an unfamiliar platform (web development shops writing a desktop application)
    • Doing something perceived as “hard” (fuzzy matching with genetic algorithms)

    Fear of the unknown drives too many decisions in software development.

    A Pattern

    The next time your user asks for something and your first impulse is to start assessing the risks involved – STOP.

    Think about the possibilities first. Think about the value to the user. Could this request make the software great? If not, how could it be even better? What can you do in this area to empower the user? How can the software truly transform their job, or their business? What could you change about your technology to make this work? What could you change about your team to make this work? What could you change about your company to make this work? How many days would you really need to experiment with something new and different? Only after you understand the true potential of what is possible can you can put on your engineering hat and assess the risks.

    We all work with limited resources and deadlines, but we often use these constraints as excuses instead of parameters in a formula for victory.

    Only courage allows us to find the true potential of software. Only courage allows us to recognize our weaknesses and try something new. Only courage allows us to explore unfamiliar landscapes in the world of software development.Only courage will allow us to align our goals with the goals of the user, make our software great, and give us a shot at undisputed victory.

    --

    I want to say thanks to @SaraJChipps for having the courage to organize this novel event, and inviting me to speak. And thanks to everyone who had the courage to come and share their stories and laugh in the rain. Concept Camp 2009 was a success, and I can’t wait for the next one! I just hope the weather is a little better …

  • Announcing the WebsiteSpark Program

    I’m excited to announce a new program – WebsiteSpark – that Microsoft is launching today.

    WebsiteSpark is designed for independent web developers and web development companies that build web applications and web sites on behalf of others.  It enables you to get software, support and business resources from Microsoft at no cost for three years, and enables you to expand your business and build great web solutions using ASP.NET, Silverlight, SharePoint and PHP, and the open source applications built on top of them.

    What does the program provide?

    WebSiteSpark provides software licenses that you can use for three years at no cost.  Once enrolled, you can download and immediately use the following software from Microsoft:

    • 3 licenses of Visual Studio 2008 Professional Edition
    • 1 license of Expression Studio 3 (which includes Expression Blend, Sketchflow, and Web)
    • 2 licenses of Expression Web 3
    • 4 processor licenses of Windows Web Server 2008 R2
    • 4 processor licenses of SQL Server 2008 Web Edition
    • DotNetPanel control panel (enabling easy remote/hosted management of your servers)

    The Windows Server and SQL Server licenses can be used for both development and production deployment.  You can either self-host the servers on your own, or use the licenses with a hoster.  WebsiteSpark makes it easy to find hosters who are also enrolled in the program, and who can use your licenses to provide you with either dedicated or virtual dedicated servers to host your sites on.

    In addition to software, WebsiteSpark provides partner opportunities to grow and build your business (including customer referrals through our partner programs).  It also includes product support (including 2 professional support incidents) and free online training for the products.

    Who can join the program?

    WebSiteSpark is available to independent web developers and small web development companies.  The only two requirements to join the program are:

    1. Your company builds web sites and web application on behalf of others.
    2. Your company currently has less than 10 employees.

    If you meet these requirements you can visit the WebsiteSpark website and sign-up today. 

    As part of the enrollment process you can pick either a network referral partner (for example: a hoster or an existing Microsoft partner), or enter a referral code that you have received at an event or from a Microsoft employee.  If you send mail to webspark@microsoft.com you can get a referral code quickly.  You can then use that code to enroll in the program on the WebsiteSpark website.  Once enrolled you can immediately download and use the software, as well as begin to participate in the network/partner opportunities.

    If you have any problems enrolling, you can also send me mail (scottgu@microsoft.com) and I can connect you with someone who can help. 

    What happens after the 3 years?

    WebsiteSpark is a 3 year program.  There is no obligation to continue to use any of the software after the three years is over, and there are no costs for the three years other than a $100 program fee at the end of the three years.

    At the end of the three years, WebsiteSpark participants can optionally choose to purchase all of the software in the WebsiteSpark program via a $999/year package.  This includes 3 copies of VS Professional, 1 copy of Expression Studio (including Blend and Sketchflow), 2 copies of Expression Web, and 4 processor licenses of Windows Web Server 2008 and 4 processor licenses of SQL Server Web edition that can be used for production deployment.

    Alternatively, if you want to purchase only the production server licenses, you can take advantage of a $199/year offering that includes both 1 Windows Web Server processor license and 1 SQL Server Web edition processor license.  You can buy the quantity you need of this package at $199/year each. 

    Summary

    The WebsiteSpark program joins the other two successful “Spark” programs we’ve previously launched - BizSpark for startups, and DreamSpark for students.

    Coming at a time when the current economic climate is still tough, WebsiteSpark will help support developers and companies by providing the business resources, training, and software necessary for companies to get started and grow successful businesses on the Microsoft Web Platform.

    Visit www.microsoft.com/web to learn more about the Microsoft Web Platform, as well as download and install the new Microsoft Web Platform Installer V2 we released today – which makes it really easy to quickly provision web servers and web development machines.  You can then browse and download and use open source web applications from the Windows Web Application Gallery.

    Hope this helps,

    Scott

    P.S. In addition to blogging, I have been using Twitter more recently to-do quick posts and share links.  You can follow me on Twitter at: http://www.twitter.com/scottgu (@scottgu is my twitter name)

  • Tip/Trick: Increase your VS screen real estate by disabling HTML Navigation Bar

    Below is a tip/trick I twittered via my Twitter account earlier today.  A number of people seemed interested in – so I thought i'd blog it here too.

    HTML Navigation Bar in VS 2008

    By default, when you are in HTML source-editing mode with VS 2008 and Visual Web Developer 2008 Express edition there is a set of drop-downs that are rendered immediately above the HTML text editor view:

    step1

    This set of drop-downs is called the "Navigation Bar", and in the VS 2008 HTML editor they allow you to navigate between functions and methods defined within the HTML.  These include both JavaScript client-side functions defined inline within the .aspx/.html file, and server-side methods defined in-line within the .aspx file when in single-file mode (meaning no code-behind file).

    Disabling the HTML Navigation Bar and Getting back some pixels

    Personally I don't find the HTML navigation bar super useful – since I tend not to define JavaScript functions inline within the HTML (instead I use more unobtrusive JavaScript techniques and put my JavaScript code in separate files), and I usually use code-behind instead of single-file event handlers for server-side code.

    If you are like me and also don't find yourself using that particular navigation toolbar much, you'll be happy to know that you can turn it off in VS 2008 and get back about 40-50 pixels that can instead be applied toward your HTML source code view.  To-do this, just select the Tools->Options menu item within VS, navigate to the "Text Editor->HTML" node and uncheck the "Navigation Bar" checkbox option:

    step2

    Once you do this and press the "ok" button, you'll find that the drop-downs are gone and you have more screen real estate:

    step3

    (Note: if there is no immediate change after you hit ok, try closing and then re-opening the HTML/ASP.NET file)

    Hope this helps,

    Scott

    P.S. By default with VS 2010 (starting with Beta2) we are hiding the navigation bar when in HTML mode with the standard web profile – you can then turn it back on via Tools->Options if you find it useful.  VS 2010 also has a new optional "code optimized" web profile as well that turns off all toolbars, dropdown and HTML designers.

  • Simple .NET Developer Survey

    If you would like a chance to win one of five $100 vouchers to spend at Amazon then take this short (< 10 minutes) survey about .NET tools: http://www.questionpro.com/akira/TakeSurvey?id=1325041

    It's not me doing the survey this time, although I do still have some results to post from the last survey.

    -James

  • Raleigh Code Camp this Saturday

    It's that time of year again and Trinug is putting on the annual Raleigh Code Camp. I swore I wouldn't do a presentation this year but I got talked into it at the last minute. I am going to be doing a tools talk about analyzing the performance of ASP.NET web applications:

    Measuring and improving the performance of your ASP.NET applications

    This session will be a walkthrough of measuring and improving all aspects of an ASP.NET application. It will consist of coding, testing, monitoring, and making performance improvements using tools like RedGate's ANTS Profiler and Firebug and maybe even some Ruby or Python. There will be no slides, you have been warned.

    I also thought it would be fun to do something other than a straight-forward presentation so I am going to be holding a coding competition. Bring your laptop and stop in to the Library during any session after lunch for a break from staring at bullet points and shiny demos.

    Coding Competition

    Do you have what it takes? Join us for a fun coding competition where you will implement a simple interface and then have your bot fight against other developer bots. Each round introduces a new challenge and through clever strategies, good code, and some reverse engineering of your opponents great riches will be yours (ok, probably just some books)

    -James

  • True RSS Feed Bankrupcy

    People like to refer to the act of marking all of their feeds as read as declaring RSS bankruptcy. They get to clear out all the items and start fresh. I realized recently that I needed to declare a true RSS feed bankruptcy and delete all of the RSS subscriptions I had collected over time. I had well over 300 subscriptions, many of them were to blogs that weren't active or on topics I wasn't particularly interested in anymore. Some of those subscriptions were from back in 2003 or earlier and were moved from Feeddemon to Bloglines to Google Reader.

    I did this because I realized two things. The first is that I wasn't keeping up with the feeds and they had simply become a burden. I used to rely on feeds to keep up with the community, but now I rely much more on twitter to do that. I also realized I was becoming interested in much different things. A large portion of my feeds were .NET related, and while I am still interested in .NET, my focus in the area has become paper thin. I care about ASP.NET MVC and changes to C#. Everything else .NET has just become noise to me.

    I have also found Hacker News which I rely on more and more for news and community. It has not only become a great place for startup related news, but chances are any major Ruby, Python, Erlang, Scala, Clojure, or NoSQL announcement will find it's way there. (and even some .NET topics).

    I have realized that there are only two types of blogs I really want to subscribe to. Blogs that consistently deliver valuable technical content or business advice, or blogs of people I consider friends. I look forward slowing re-building a much leaner list of feeds and hopefully returning to getting value out of my blog reader.

    -James

  • Announcing the Microsoft AJAX CDN

    Earlier today the ASP.NET team launched a new Microsoft Ajax CDN (Content Delivery Network) service that provides caching support for AJAX libraries (including jQuery and ASP.NET AJAX).  The service is available for free, does not require any registration, and can be used for both commercial and non-commercial purposes.

    What does a CDN provide?

    Content delivery networks (CDNs) are composed of "edge cache" servers that are strategically placed around the world at key Internet network points.  These "edge cache" servers can be used to cache and deliver all types of content – including images, videos, CSS and JavaScript files.

    Using a CDN can significantly improve a website's end-user performance, since it enables browsers to more quickly retrieve and download content.  For example, instead of having a browser request for an image traverse all the way across the Internet to your web server to download, a CDN can instead serve the request directly from a nearby "edge cache" server that might only be a single network hop away from your customer (making it return much faster – which makes your pages load quicker). 

    What does the Microsoft AJAX CDN provide?

    The Microsoft AJAX CDN makes it really easy to add the jQuery and ASP.NET AJAX script libraries to your web sites, and have them be automatically served from one of our thousands of geo-located edge-cache servers around the world. 

    For example, if you want to use jQuery from the Microsoft AJAX CDN then you can simply add a standard script tag to your page using the URL below:

       <script src="http://ajax.microsoft.com/ajax/jquery-1.3.2.min.js" type="text/javascript"></script>   

    When the browser requests the script file it will be automatically served by the CDN "edge cache" server that is closest to the end-user.  This means:

    • The request will be processed much faster than if it had to hit your web-server (making the end-user's page load much faster)
    • You don't have to pay for the bandwidth of this file – since the file comes from our server we pay the bandwidth cost (saving you money)
    • The script can be easily cached across multiple web-sites – which means it might not even need to be downloaded if the user has already hit a web-site that requested the file (and as such has it already in the browser's cache). 

    You can get a full listing of the JavaScript libraries (and associated URLs) we already have loaded in our CDN cache here: www.asp.net/ajax/cdn 

    We'll update the available libraries in the CDN as we ship new versions of ASP.NET AJAX, and continue to update it to include all of the JavaScript files we ship with ASP.NET and Visual Studio (including jQuery, the jQuery Validation plugin, and additional libraries we ship in the future). 

    The CDN service is free and available for anyone in the community to use for both commercial and non-commercial purposes.  You do not need to register to take advantage of it.

    Using the Microsoft AJAX CDN with the ASP.NET 4.0 ScriptManager

    In addition to allowing you to reference script files directly using a <script> element, ASP.NET 4.0 will make it easy to use the CDN from ASP.NET Web Forms applications that use the <asp:scriptmanager/> server control. 

    The ASP.NET 4.0 <asp:ScriptManager> control includes a new property named EnableCdn. When you assign the value true to this property, your application will use the Microsoft CDN to request JavaScript files automatically:

    scriptmanager

    When you enable the CDN with the ScriptManager, your application will retrieve all JavaScript files that it normally retrieves from the System.Web.dll or System.Web.Extensions.dll assemblies from the CDN instead.  This includes both the JavaScript files within ASP.NET AJAX, as well as the built-in Web Forms JavaScript files (for example: the WebUIValidation.js file for client-side validation, and the JavaScript files for controls like TreeView, Menu, etc).

    This provides a nice end-user performance improvement, and means that users accessing your ASP.NET website won’t need to re-download these files if they have visited another ASP.NET website that uses the CDN.

    Using ASP.NET AJAX Preview 5 from the CDN

    In addition to launching the AJAX CDN site, the ASP.NET team has also recently released ASP.NET AJAX Preview 5. You can download ASP.NET AJAX Preview 5 (with sample code) from CodePlex: http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=32770

    You can also now use the ASP.NET AJAX libraries simply by adding the following script tags that point at the CDN:

        <script src="http://ajax.microsoft.com/ajax/beta/0909/MicrosoftAjax.js" type="text/javascript"></script>

        <script src="http://ajax.microsoft.com/ajax/beta/0909/MicrosoftAjaxTemplates.js" type="text/javascript"></script>

    These script tags reference the beta version of the September 2009 release of the ASP.NET AJAX library (the /0909/ part of the URL represents the year and month that the version of ASP.NET AJAX was released). 

    After you add script tags that reference the ASP.NET AJAX library, you can start using the library in your page. For example, the following code attaches a client DataView control that represents an array of photos to a DIV element in the body of the page.

    data 

    The DIV element – with an id of "photos" – contains a template for formatting each photo in the array of photos. Here’s how the photos element is declared:

    template

    When the DataView is rendered, the contents of the photos DIV element is rendered for each photo in the array of photos. The following photos are displayed:

    photos

    Because ASP.NET AJAX is a pure JavaScript library, the code above works perfectly well in an ASP.NET Web Forms, ASP.NET MVC, HTML, or even with classic Active Server Pages. The code also works with all modern browsers.

    You can learn more about ASP.NET AJAX Preview 5 by downloading the sample code from the CodePlex project:  http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=32770

    Below are several blog posts that delve into the features of ASP.NET AJAX Preview 5 in more depth:

      Summary

      The Microsoft Ajax CDN enables you to significantly improve the performance of ASP.NET Web Forms and ASP.NET MVC applications that use ASP.NET AJAX or jQuery.  The service is available for free, does not require any registration, and can be used for both commercial and non-commercial purposes.

      ASP.NET 4.0 will make it especially easy for ASP.NET Web Forms developers to take advantage of the CDN. By setting one property of the ScriptManager control, you will be able to redirect all requests for the built-in ASP.NET JavaScript files to the CDN and improve the performance of your Web Forms applications.

      Hope this helps,

      Scott

    • Auto-Start ASP.NET Applications (VS 2010 and .NET 4.0 Series)

      This is the seventh in a series of blog posts I’m doing on the upcoming VS 2010 and .NET 4 release.

      I’m going to switch from discussing new VS 2010 tooling features and instead do a few posts covering a few new runtime features (don’t worry – I’ll come back to a lot more VS features, I’m just trying to mix things up a bit).

      Today’s post covers a small, but nice, new feature that you can now optionally take advantage of with ASP.NET 4 - the ability to automatically startup and proactively initialize a web application without having to wait for an external client to hit the web server.  This can help you provide a faster response experience for the first user who hits the server, and avoids you having to write custom scripts to “warm up” the server and get any data caches ready.  It works with all types of ASP.NET applications – including both ASP.NET Web Forms and ASP.NET MVC based applications.

      Auto-Start Web Applications with ASP.NET 4

      Some web applications need to load large amounts of data, or perform expensive initialization processing, before they are ready to process requests.  Developers using ASP.NET today often do this work using the “Application_Start” event handler within the Global.asax file of an application (which fires the first time a request executes).  They then either devise custom scripts to send fake requests to the application to periodically “wake it up” and execute this code before a customer hits it, or simply cause the unfortunate first customer that accesses the application to wait while this logic finishes before processing the request (which can lead to a long delay for them).

      ASP.NET 4 ships with a new feature called “auto-start” that better addresses this scenario, and is available when ASP.NET 4 runs on IIS 7.5 (which ships with Windows 7 and Windows Server 2008 R2).  The auto-start feature provides a controlled approach for starting up an application worker process, initializing an ASP.NET application, and then accepting HTTP requests.

      Configuring an ASP.NET 4 Application to Auto-Start

      To use the ASP.NET 4 auto-start feature, you first configure the IIS “application pool” worker process that the application runs within to automatically startup when the web-server first loads.  You can do this by opening up the IIS 7.5 applicationHost.config file (C:\Windows\System32\inetsrv\config\applicationHost.config) and by adding a startMode=”AlwaysRunning” attribute to the appropriate <applicationPools> entry:

      <applicationPools>

           <add name="MyAppWorkerProcess" managedRuntimeVersion="v4.0" startMode="AlwaysRunning" />

      </applicationPools>

      If you load up the Windows task manager, click the “show processes from all users” checkbox, and then hit save on a startMode attribute change to the applicationHost.config file, you’ll see a new “w3wp.exe” worker process immediately startup as soon as the file is saved.

      A single IIS application pool worker process can host multiple ASP.NET applications.  You can specify which applications you want to have automatically start when the worker process loads by adding a serviceAutoStartEnabled="true" attribute on their <application> configuration entry:

      <sites>

           <site name="MySite" id="1">

                <application path="/" serviceAutoStartEnabled="true" serviceAutoStartProvider="PreWarmMyCache" />

           </site>

      </sites>

      <serviceAutoStartProviders>

           <add name="PreWarmMyCache" type="PreWarmCache, MyAssembly" />

      </serviceAutoStartProviders>

      The serviceAutoProvider="PreWarmMyCache" attribute above references a provider entry within the config file that enables you to configure a custom class that can be used to encapsulate any "warming up" logic for the application.  This class will be automatically invoked as soon as the worker process and application are preloaded (before any external web requests are received), and can be used to execute any initialization or cache loading logic you want to run before requests are received and processed:

      public class PreWarmCache : System.Web.Hosting.IProcessHostPreloadClient {

          public void Preload(string[] parameters) {

              // Perform initialization and cache loading logic here...

          }

      }

      IIS will start the application in a state during which it will not accept requests until your "warming up" logic has completed.  After your initialization code runs in the Preload method and the method returns, the ASP.NET application will be marked as ready to process requests. 

      You can optionally combine the new auto-start "warming up" feature with the load-balancing capabilities of the IIS7 Application Request Routing (ARR) extension, and use it to signal to a load-balancer once the application is initialized and ready to accept HTTP traffic – at which point the server can be brought into the web farm to process requests.

      Summary

      The new "auto start" feature of ASP.NET 4 and IIS 7.5 provides a well-defined approach that allows you to perform expensive application startup and pre-cache logic that can run before any end-users hit your application.  This enables you to have your application "warmed up" and ready from the very beginning, and deliver a consistent high performance experience.

      Hope this helps,

      Scott

      P.S. In addition to blogging, I have been using Twitter more recently to-do quick posts and share links.  You can follow me on Twitter at: http://www.twitter.com/scottgu (@scottgu is my twitter name)

    • Your idea will probably change

      When I took over The Lounge back in December of 2007 I looked at it as a great way to make a little extra money each month, but not a ton more than that. As it grew, and after I launched Ruby Row, I started to see that advertising networks could be a good little business. I liked working with publishers and the advertising sales side wasn't all that hard. As time passed though I began to realize a couple of things.

      I am competent at sales, but not much better than that. I am bad at organization and scheduling and I don't have the nerves to handle doing things like cold calls. I figured out I am basically good at customer relations and taking orders, but not pushing sales. This is of course a large part of running an advertising network and when I realized I didn't want to do sales for a living it made me realize that building ad networks might not be the best business for me. I am in talks with a company to actually take over most of the sales for The Lounge which will help that network grow and keep the sales burden off of me, this alleviates the long-term issue but when starting a network it would be tough to outsource the sales from the beginning.

      The second thing I realized is that most publishers aren't that faithful. They will quickly leave your network for the next big thing or the next network that offers them a better rate. I am actually lucky in that most of my publishers feel some allegiance to me, but after a number of them left to a competitor and put the future of the network in jeopardy I learned that I couldn't rely on allegiance alone and made some compromises that hurt my overall margin. This is something you constantly see with the larger networks, they all fight over large publishers and push their rates lower and lower.

      When I decided to go full-time on The Lounge and Ruby Row in January my plan was still to build additional networks to get myself to a sustainable level of income and then see where to go from there. I started to build The Branch, a network focused on advertising to Twitter users. I made a couple of mistakes on The Branch. The first was I did not realize how general the Twitter audience had become by this time, at one point it was a very influential group of people but in the last 18-24 months it has become almost as general an audience as Facebook. My second mistake was that I tried to launch with some of the largest twitter applications out there, which put a huge sales burden on me. Launching an ad network is an interesting problem since you need to get publishers to commit to draw advertisers, but if you don't draw enough advertisers quickly enough you can't keep the publishers. Needless to say The Branch didn't work out and I ended up shuttering it before it even officially launched.

      After the failure of The Branch I started to think about why The Lounge and Ruby Row have done so well. The Lounge continues to grow because I know the .NET community, I know the publishers I want and I know what companies to approach about advertising. Ruby Row continues to grow because of my great partner on the project, Geoffrey Grosenbach, and because it is such a great niche market. I am also somewhat involved in the Ruby community so I know who I want in the network and what companies to approach. In both cases I had an inside person in the community which made all the difference.

      My next thought was to simply find a good contact in another nich community to try and launch a network, I have tried to do this in a number of other niche markets and have had a hard time finding a reliable, motivated individual to partner with. It turns out I got very lucky with Geoffrey and finding people like him in other markets wasn't going to be easy.

      So my focus has completely shifted away from building new advertising networks. I am not saying that I won't launch a new network in the future, if the right individual or idea comes up I would definitely do it, but I am not relying on it to float my business anymore. My focus has shifted for the moment to building Ruby Row and The Lounge into the largest and most successful networks they can be to keep my business sustainable while I work on my next big idea... which I am not yet ready to talk about.

      The real lesson I have learned is that the idea you start out with probably won't be the idea you end up with. So don't hold on to it too tightly and don't worry about failure, its just the quickest way to learn.

      -James

    • September's Toolbox Column Now Online

      My Toolbox column in the September 2009 issue of MSDN Magazine is available online and includes the following reviews/discussions:

      • Improving Web Application Performance With Distributed Caching - provides an overview of distributed caching for web applications, with discussions on three products: memcached, an open source option that powers many high-profile sites like LiveJournal, Wikipedia, and SourceForge; Velocity, which is Microsoft's foray into the distributed caching market; and third-party commercial implementations, like ScaleOut Software's ScaleOut StateServer and Alachisoft's NCache, which was reviewed in the October 2007 issue.
      • Blogs of Note: Udi Dahan - Udi is a speaker, trainer, and consultant on software architecture and design of distributed systems. He has worked on several large-scale, service-oriented applications for enterprises, and blogs about his experiences building enterprise applications on his blog. Check out the 'First time here?' page on Udi's blog, which has links to his most popular and engaging articles and blog posts.
      • AutoMapper - it's not uncommon to need to transfer objects of one 'shape' into a different shape. This is particularly common when exposing data through a service layer. Internally, you work with your entities in terms of business objects that model your domain, but when exposing this data you may need to return a more appropriate object type that contains fewer properties. These objects used in the service layer are referred to as Data Transfer Objects (DTOs). Writing the domain object to DTO mapping code is tedious. AutoMapper, a free, open source project - helps relieve that tedium by making such object-object mappings as easy as writing two lines of code.

      This issue did not include a book review.

      Enjoy! - http://msdn.microsoft.com/en-us/magazine/ee413550.aspx

      As always, if you have any suggestions for products, blogs, or books to review for the Toolbox column, please send them to toolsmm@microsoft.com.

    • Stockholm

      During the last week of August I was in Stockholm, Sweden to deliver two of the twelve workshops at Øredev's Progressive .NET Days. The workshops were split across 3 tracks and covered  prevailing software development topics like NHibernate, DDD, DSLs, Git, and dynamic languages. Based on the feedback I’ve heard, the workshops were considered a success by everyone who participated. But, what left a lasting impression on me was the unbounded hospitality of the event organizers, attendees, and Stockholm itself.

      Meeting Michael Tiberg of Oredev

       

      On the first evening that I ever spent in Stockholm I was greeted by Michael Tiberg, the CEO of Oredev. We strolled across modern roads into the medieval, cobblestoned streets of Old Town Stockholm – Gamla stan. Michael was my personal tour guide and pointed out sites. I saw Stockholm City Hall - a stalwart building made of red brick and home to Nobel Prize ceremonies and banquets. I also saw the rounded backside of the Swedish Parliament building, and facades of the Stockholm Palace.

      Michael didn’t know I was a fan of Jazz music when we entered Stampen that evening. In the 17th century, this building was a French Reform church, but since 1968 it’s been a jazz pub. The vocalist of the 5 piece band playing that evening would belt out jazz classics in English, then banter with the growing crowd in Swedish. The last song we heard before leaving was Billie Holiday’s God Bless The Child – a personal favorite.

      Jazz at the Stampen

      Within a day I decided that Stockholm is a quiet city, but quiet isn’t the same as sleepy, or empty. People are everywhere in downtown Stockholm. Commuters wheel past in the dedicated bike lanes and swarm into metro openings. Taxis and tourist buses jockey politely for curb space. But something was audibly missing - the insecure blustering I’m so accustomed to hearing in the metro areas of the Northeast United States – no horns blowing, no people shouting, no music blaring. In Stockholm, even the sidewalk hawkers stand quietly on the corner wearing sandwich board signs to advertise lunch specials.

      The quiet in the city gives you the chance to hear people laugh. They laugh as they talk on cell phones, and they laugh in crowds under the open awnings of cafes. The Swedes I met paint  themselves as reserved, and present themselves as self-assured and happy.

      City square 

      I took home many fond memories from Stockholm, including a trip to an Ice Bar (thanks Magnus), and some great technical discussions with other speakers and attendees. The last evening I spent chatting and dining with guys from Nansen – a local and fast growing web development firm. We talked about software development, health care, politics (I met at least two members of the Swedish Pirate Party during the week), religion, the size of American cars, and XBOX games. I hope to return one day and experience more of Stockholm, and I’m already looking forward to the main Øredev conference this fall in Malmö.

    • A Tool For Querying Multiple Databases

      I recently blogged about different multi-tenant data architectures, comparing and constrasting the Separate Databases and Shared Database, Shared Schema architectures, as well as noting what sorts of questions to ask when trying to ascertain which model to use. One of the disadvantages of the Separate Databases approach is that it can be difficult to view data aggregated across the databases:

      Viewing data aggregated across the databases is difficult. I've touched upon this topic in an earlier blog post, Running the Same Query Against Multiple Databases. When you find a bug on one database and need to see whether it affects data in other databases there are not many tools at your disposal. One poor man's tool is sp_msForEachDb, but it's less than ideal.

      And reader John Chapman added his two cents in the comments regarding this issue:

      For lots of applications you actually have situations where there are users who need to be able to see data from multiple customers at the same time. For example you may have situations where you have external customers who see only their data, but yet have internal liaisons who need to oversee the activities of multiple customers. Therefore necessitating that they see data from multiple customers on a single screen.

      I have ran into these situations before, which was a key reason why we used a single database shared schema. The application we replaced used separate databases and was unable to provide this sort of functionality.

      Over the years I have created a very (very!) rough tool for querying multiple databases in a Separate Databases architecture. In short, you enter a query, select which databases to query against, and then the tool runs that query against each selected database and combines the results into a single <table> on the page. As you can see from the screen shot below (click for a larger version), the tool includes a multi-line textbox for entering the query to execute and a CheckBoxList of the databases to query. The results are included in a single <table>.

      While the above screen shot shows a query that just returns a scalar value (one column, one row), it certainly works with queries that return multiple rows and columns. And with a little bit of legwork the tool could be enhanced to include rollup-type functionality, showing subtotals per database and grand totals across all selected databases for numeric columns.

      To learn more about how I created this tool, check out my latest 4GuysFromRolla.com article: Querying a Multi-Tenant Data Architecture.

    • Review: The 36-Hour Day

      The 36-Hour Day is a book to buy if someone you love is growing a little older, and perhaps growing a little confused, too. The book is about memory loss and dementias like Alzheimer’s disease. It will give you information and strategies you need to care for your loved one, but more importantly, it gives you a perspective and understanding of what your loved one experiences as their illness transforms their behavior and memory.

      I have an easy time finding quality technical content on the Internet, but I struggled finding good resources on this topic. The articles on dementia live in a wasteland of superficial prose, smeared by pointless advertisements. The 36-Hour Day : A Family Guide to Caring for Persons With Alzheimer Disease, Related Dementing Illnesses, and Memory Loss in Later Life is packed with advice to deal with the emotional, legal, medical, nutritional, and behavioral aspects of a heartbreaking situation. Kudos to the authors Nancy Mace and Peter Rabins.

      The book will help you care for the person you love.

      The book will help you care for yourself.

      I highly recommend it.

    • ASP.NET, HTML, JavaScript Snippet Support (VS 2010 and .NET 4.0 Series)

      This is the sixth in a series of blog posts I’m doing on the upcoming VS 2010 and .NET 4 release.

      Today’s post covers another useful improvement in VS 2010 – HTML/ASP.NET/JavaScript snippet support.  Snippets allow you to be more productive within source view by allowing you to create chunks of code and markup that you can quickly apply and use in your application with a minimum of character typing.

      Visual Studio has supported the concept of “snippets” for VB and C# in previous releases – but not for HTML, ASP.NET markup and JavaScript.  With VS 2010 we now support snippets for these content types as well.

      Using ASP.NET Snippets

      Let’s walkthrough how we can use snippets to quickly implement a common security scenario.  Specifically, we’ll implement the functionality necessary to display either a “[ Login ]” link or a “[ Welcome UserName ]” message at the the top right of a site depending on whether or not the user is logged in:

      step1

      The above functionality is automatically added for you when you create a project using the new ASP.NET Project Starter Template in VS 2010.  For the purpose of this walkthrough, though, we’ll assume we are starting with a blank master page and will build it entirely from scratch.

      We’ll start by adding a standard <div> element to a master page, and then position our cursor within it:

      step2

      We are going to use the built-in <asp:loginview> control to help implement our scenario.  The <asp:loginview> control is a templated control (first introduced with ASP.NET 2.0) that allows us to easily switch between “Anonymous” and “LoggedIn” templates that automatically display depending on whether the user is authenticated.  Rather than type the <asp:loginview> markup manually, we’ll instead use the new snippet support in VS 2010.

      Typing in “<log” in the editor will bring up intellisense and display available elements, controls and code snippets that start with those characters.

      step3

      We’ll select the built-in “loginview” code snippet from the above list and hit the “tab” key to complete it:

      step4

      Now that we’ve selected the snippet we want to use, we can hit the “tab” key again to execute the snippet – which will cause it to immediately replace the snippet name with the markup below.  Notice below the snippet added a new <asp:loginview> control for us and automatically defined the two most commonly used templates on it.  We were able to implement that all with just 6 keystrokes (4 keystrokes to type “<log”, and then 2 tab keystrokes).

      step5

      We’ll now implement the “AnonymousTemplate”.

      Typing in “<a” in the editor will being up intellisense and display available elements and code-snippets we can use:

      step6

      We’ll select the built-in “a” code snippet from the above list and hit the “tab” key to complete it.  When we hit tab again it will execute the snippet – which will cause it to replace the snippet name with the markup below:

      step7

      The “href” attribute attribute value and the inner content of the <a> element above are highlighted with a green background color.  This indicates that these values are replaceable parameters and that we can automatically tab between them when filling them out – avoiding the need to use the cursor keys or touch the mouse (making things much faster).

      Without having to move our cursor or mouse, we can begin typing the login page URL we want to send users to if they are not authenticated on the site:

      step8

      When done, we can hit the “tab” key and VS will automatically highlight the second content parameter in the editor for us (no manual cursor movement or mouse action required):

      step9

      We can then type the text we want displayed (again without having to move the mouse or touch a cursor key):

      step10

      Once done with the “<AnonymousTemplate>” we can move onto the "<LoggedInTemplate>”.  We’ll type “<log” in the editor to bring up intellisense – and select the built-in “loginname” snippet:

      step11

      When we hit tab it will execute the snippet – which will cause it to replace the snippet with the markup below:

      step12

      The “FormatString” property value above was automatically populated for us with a default welcome text message.  The value is also automatically highlighted in case we want to change it (without having to move the mouse or cursor keys).  For this sample we’ll just keep the default text.

      Our final markup then looks like below:

      step13

      When we run our application the above markup will display a “[Login]” link when we aren’t authenticated:

      step19

      When we are logged in we’ll see a welcome string like below:

      step15

      The total number of key strokes to implement this entire scenario is less than 15% of what we would previously have had to type.  Typing fast, I found I could implement the entire scenario in less than 15 seconds :-)

      ASP.NET MVC Snippets

      Built-in snippets are available for all ASP.NET controls and HTML markup elements. 

      Built-in snippets are also available for common ASP.NET MVC view scenarios, and for the built-in ASP.NET MVC HTML helpers. 

      For example, we can type “<act” within a ASP.NET MVC view and select the “actionlink” snippet:

      step16

      When we complete it and hit the “tab” key the snippet will execute – which will cause it to replace the snippet name with the markup below:

      step17

      Notice that the “linktext” and “actionname” values are marked as snippet parameters – which means we can easily replace them without having to use the cursor keys or touch the mouse.  The first linktext parameter value is selected by default – which means we can just type to immediately replace the value, then hit tab to immediately select and replace the second actionname parameter:

      step18

      Custom Snippets

      Visual Studio 2010 will include more than 200 built-in snippets that you can immediately use when you install the product.

      What is really nice is that you are not limited to only using the built-in snippets.  You can also easily create your own snippets (complete with replaceable parameters) and both import them into VS 2010, as well as easily share them with other developers.  This makes it easy for you to quickly automate your own common tasks.

      This article describes the snippet support that already exists in VS 2008, and provides a little more context on how to create and manage custom snippets.

      Summary

      Snippets are a useful feature that enable you to reduce keystrokes within the editor, and allow you to complete scenarios and tasks much faster.  Having snippets now enabled in not just VB and C#, but also in HTML, ASP.NET and JavaScript files, makes this capability even more useful – and can make you even more productive.

      Hope this helps,

      Scott

      P.S. In addition to blogging, I have been using Twitter more recently to-do quick posts and share links.  You can follow me on Twitter at: http://www.twitter.com/scottgu (@scottgu is my twitter name)

    • Video &#8211; Reuni&oacute;n ALT .NET Caf&eacute; 29 De Agosto &laquo; BeyondNet

      Pingback from  Video &#8211; Reuni&oacute;n ALT .NET Caf&eacute; 29 De Agosto &laquo;  BeyondNet

    • Code Optimized Web Development Profile (VS 2010 and .NET 4.0 Series)

      This is the fifth in a series of blog posts I’m doing on the upcoming VS 2010 and .NET 4 release.

      Today’s post covers a new “Web Development (Code Optimized)” profile option we are introducing with VS 2010 that allows you to optionally configure Visual Studio to run in an IDE layout mode that hides the WYSIWYG web designer and instead optimizes around a rich “source editing focused” tooling experience.

      VS 2010 Web Profiles

      When you first run VS 2010 it prompts you to select an IDE profile to use.  The profile you select will configure how tool windows are displayed/docked in the IDE by default and set the default keyboard shortcuts.  You can then customize any of these settings by using the Tools->Options menu within the IDE and then override/change them.  You can also later reset your profile and pick a different one by choosing the Tools->Import and Export Settings menu command.

      One of the things you’ll notice when you run VS 2010 Beta2 for the first time is the inclusion of two “Web Development” profiles in the list of options:

      0 Choose Default Environment Settings

      The first “Web Development” profile option is an evolution of the existing web development profile option from VS 2008 (with some nice improvements that help improve screen real estate usage with VS 2010).  It also allows you to take advantage of all the great WYSIWYG HTML and ASP.NET Page designer improvements we’ve done with the VS 2010 release (I’ll cover these in more detail in later blog posts in this series).

      The second “Web Development (Code Optimized)” profile option is a new profile we are introducing with VS 2010 that is optimized for web developers who do not want to use a WYSIWYG designer when doing their web development, and who prefer a “source only” editing experience when working on pages.  This IDE profile option hides the WYWISYG page designer tabs, and configures a default IDE layout that maximizes the amount of code that is displayed on the screen (with a minimum of toolbars and tool windows).  It still provides a full intellisense/debugging and source editor experience for pages.

      Comparing the VS 2010 Web Development Profiles

      You can get a sense of the difference between the two profiles by comparing screen-shots of the Visual Studio IDE layout immediately after the two different “Web Development” profiles are applied:

      Screenshot of the “Web Development” Profile:

      The layout below demonstrates the default IDE layout (at a 750x650 monitor resolution) when the standard “Web Development” profile is applied.  This profile is an evolution of the existing “Web Development” profile in VS 2008 and exposes design/split/source tabs within the document window of any HTML or ASP.NET page:

      1 Old Profile Small IDE

      Screenshot of the “Web Development (Code Optimized)” Profile:

      The screen-shot below demonstrates the default IDE layout (at a 750x650 monitor resolution) when the new “Web Development (Code Optimized)” profile is applied.  As you can see, the profile optimizes the screen real estate around displaying and editing code on the screen, hides all toolbars by default, and disables and hides the designer tabs within the document windows of HTML and ASP.NET pages:

      2 New Profile Small IDE

      Below is a screen-shot of the “code optimized” profile at a larger monitor resolution:

      2 New Profile Full IDE Single File

      Mixing and Matching Features

      All of the different features used in both the standard “Web Development” profile and the “Web Development (code optimized)” profile are exposed via Visual Studio’s Tools->Options configuration dialog.  This means that you can start with any of the VS profiles (including the General, VB and C# profiles) and turn on or off individual features to customize the IDE layout and editing experience however you want it to be.

      For example: below you can see the Tools->Options dialog checkbox to enable or disable the HTML designer (which will configure whether the Design/Split/Source tabs are shown at the bottom of each page):

      0 Tools Options HTML Designer

      This gives you the flexibility to customize your development experience however you want and create a personalized tooling experience optimized for you and your preferred way of doing development.

      The two web development profiles that ship in the box provide two good preconfigured starting points that we think offer a nice set of defaults for a large set of the web developers out there.  You can easily choose to start with whichever one feels best to you, and optionally configure them further however you want.

      Summary

      We are offering the new profile simply as an option for those who prefer a source-focused web development experience. The WYSIWYG HTML/ASP.NET designer continues to be enabled by default with all the other VS 2010 profiles (just like it does with VS 2008), and we have also made a lot of improvements to it with the VS 2010 release (I’ll blog more details about these in later posts).  So don’t worry – the WYSIWYG designer definitely isn’t going away, and will continue to be enhanced and improved with each release. 

      We think the new “Web Development (Code Optimized)” profile, though, is a nice new option for developers who prefer a “source editing focused” web development experience, and who do not use the WYSIWYG designer.  The profile option provides an easy way for them to hide the designer (along with its associated tool windows and toolbars) from the IDE layout and instead use a source-focused web development experience.

      Hope this helps,

      Scott

      P.S. In addition to blogging, I have been using Twitter more recently to-do quick posts and share links.  You can follow me on Twitter at: http://www.twitter.com/scottgu (@scottgu is my twitter name)

    • Multi-Monitor Support (VS 2010 and .NET 4 Series)

      This is the fourth in a series of blog posts I’m doing on the upcoming VS 2010 and .NET 4 release.

      Today’s post covers one of the general IDE improvements that I know a lot of people are already eagerly looking forward to with VS 2010 – multiple-monitor support.

      Using Multiple Monitors

      VS 2008 hosts all documents/files/designers within a single top-level window – which unfortunately means that you can’t partition the IDE across multiple monitors.

      VS 2010 addresses this by now allowing editors, designers and tool-windows to be moved outside the top-level window and positioned anywhere you want, and on any monitor on your system.  This allows you to significantly improve your use of screen real-estate, and optimize your overall development workflow.

      Taking advantage of the multi-monitor feature is really easy to-do.  Simply click on a document tab or tool-window and drag it to either a new location within the top-level IDE window – or outside of the IDE to any location on any monitor you want:

      step2

      You can later drag the document/window back into the main window if you want to re-dock it (or right click and choose the re-dock option). 

      Projects and solutions remember the last screen position of their documents when saved – which means that you can close projects and re-open them and have the layout automatically startup where you last saved it.

      Some Multi-Monitor Scenarios

      Below are some screen-shots of a few of the scenarios multi-monitor enables (obviously there are many more I’m not covering).  Pretend each window in the screenshots below is on a different monitor to get the full idea…

      Code source file support:

      Demonstrates how code files can be split up across multiple monitors.  Below I’ve kept a .aspx file in the main IDE window and then moved a code-behind file and a separate class file to a separate screen:

      step3

      Tool window support:

      Demonstrates how any tool window/pane within VS10 can be split across multiple monitors.  Below I’ve moved the test runner tool windows to a separate screen:

      step5

      Designer support:

      Demonstrates how a designer within VS can be split across multiple monitors.  Below I’ve moved the WPF/Silverlight WYSWIYG designer and the property grid to a separate screen (the code behind file is still in the main window). Note how the VS10 property grid now supports inline color editors, databinding, styles, brushes, and a whole bunch more for WPF and Silverlight applications (I’ll cover this in later blog posts):

      step6

      Summary

      If you work on a system that has multiple monitors connected to it, I think you are going to find the new multi-monitor support within VS10 a big productivity boost.

      If you don’t already have multiple monitors connected to your computer, this might be a good excuse to get some… :-)

      Hope this helps,

      Scott

      P.S. In addition to blogging, I have been using Twitter more recently to-do quick posts and share links.  You can follow me on Twitter at: http://www.twitter.com/scottgu (@scottgu is my twitter name)

    This Blog

    Syndication

    Powered by Community Server, by Telligent Systems
    '