scandalz.net
 
 
 
BETA (Google AJAX Search)

Programming

I'm putting a bunch of programming related resources here. It's always going to be a work in process since every language (except COBOL) is a work in progress. And if I catch someone working in COBOL, I'll rm -rf them

Fosimo.TR — Twitter Client for Windows

by Anatoly Lubarsky at 17:11 PM, 07/03/2009

Fosimo.TR 0.5.1 is available for download

This is the 1st publicly available version of Fosimo.TR — free twitter client for windows ultimate tool which will help you keep track of your twitter account without browsing through twitter.


Please visit Fosimo.TR download page for more details. You need to have an account on Twitter to make it work :))

Fosimo.TR key features

  • Tweet :))
  • Be updated instantly with your Twitter friends status updates.
  • Synchronize Twitter friends with matching OUTLOOK contacts. For windows mobile devices owners - you should be able to see your contacts photos on your phone display.
  • Autoupdate (Fosimo.TR autoupdates each time a new version is available).

In addition

We will never ask you for your Twitter password and you don't need to enter one on Fosimo.TR (because Fosimo.TR fully supports oAuth authentication technology). Your Fosimo.TR will be updated automatically each time there is a new version of the product. There is no need to download uninstall and reinstall the tool each time.


Another screenshot


Follow updates on @fosimo and stay tuned.


Hope you enjoy it, your feedback is much appreciated :)

Introducing Fosimo.TR — Fosimo for Twitter

by Anatoly Lubarsky at 06:48 AM, 07/03/2009

Fosimo is expanding to Twitter

We'd like to introduce a new awesome tool for Twitter, which is called Fosimo.TR and will be available in a couple of days for the public! It will change the way you tweet today and get updated with Twitter friends status updates.


In case you are not familiar with Fosimo yet. Fosimo is a free Facebook client tool for windows which helps you keep track of your Facebook account without browsing through Facebook.


Fosimo.TR is a free Twitter client for windows which is doing virtually the same but on Twitter. You can tweet, be synced instantly with friends status updates and much more including features that are not on the core Twitter.


Screenshot


As I mentioned: 1st version will be available shortly. We are already in the testing stage :)


Stay tuned :)

ASP.NET MVC Talk in Reading UK July 3rd

by ScottGu at 01:11 AM, 07/02/2009

I’m in the UK today and tomorrow (on my way back from a trip to India for two days earlier this week), and am giving two tech talks while in town. 

The first is this evening at a London .NET User Group event.  I’ll be presenting Silverlight 3.  Unfortunately the event is already over-registered – so if you haven’t registered yet you’ll need to catch it the next time I’m in town.

The second talk is tomorrow (Friday) from 1-4pm at the Microsoft facility in Reading and is on ASP.NET MVC.  When we first announced it last week it also over-registered quickly.  Thankfully my hosts were able to get a larger room this week, though, so another 120 spots became available. 

You can register to attend the talk for free until 4pm today if you want to attend.  Hurry, though, as there are only 43 seats left (down from 57 seats when I first started writing this blog post).

Hope to see some of you there,

Scott

Facebook Urls

by Anatoly Lubarsky at 20:26 PM, 06/18/2009

Facebook opened vanity urls to the public for free and during the landrush last Saturday over a million urls were taken.


What did you get?


I agree with techcrunch that the coolest personal url taken last week is default.aspx. LOL.


I got my first name: anatoly. Just the same as I own on twitter and on linkedin.


The rush will continue on June, 28th when Facebook pages urls will become fully open. Right now pages need more than 1000 fans threshold to be able to get vanity url.

MySpace Layoffs: June, 2009

by Anatoly Lubarsky at 20:11 PM, 06/18/2009

It has been nearly a month and a half since I made a post sharing my opinion on MySpace dev. platform status and here come some bad news for Myspace (and for the platform) :/


According to techcrunch Myspace reduced its staff this week by 480 people.


The bad news is that many of them are key employees and had contributed a lot to Myspace during the years. Including people from Myspace dev. platform.

Friendster: Approaching 1 Million Users

by Anatoly Lubarsky at 19:55 PM, 06/18/2009

We are quickly approaching 1 million users on Friendster. Going to hit 1 million users mark next week or so. It will be our 1st platform so far where we reach 1 million installs.


x2line has 7-8 applications on Friendster with over 50K users each. And still growing.


Go, Friendster!

Here is the latest in my link-listing series.  Also check out my ASP.NET Tips, Tricks and Tutorials page and Silverlight Tutorials page for links to popular articles I've done myself in the past.

You can also now follow me on twitter (@scottgu) where I also post links and small posts.

ASP.NET

  • GridView Confirmation Box using jQuery: Mohammed Azam has a nice post that describes how to implement model confirmation UI using jQuery.  This is particularly useful for scenarios like saving or deleting data.

AJAX

  • ASP.NET 4.0 AJAX – Client Templates: Damien White has a great post that describes the new client templating support in ASP.NET AJAX.  This provides an easy and powerful way to dynamically create rich HTML UI on the client.

  • ASP.NET 4.0 AJAX - Data Binding: Damien White continues his great ASP.NET AJAX series with this article that describes the new client-side data binding features in the new version of ASP.NET AJAX. 

ASP.NET MVC

  • DataAnnotations and ASP.NET MVC: Brad Wilson (a dev on the ASP.NET MVC team) has a nice post that describes how to use DataAnnotations to annotate model objects, and then use a model binder to automatically validate them when accepting form posted input.  DataAnnotation support will be built-in with the next version of ASP.NET MVC.

Visual Studio

Hope this helps,

Scott

IIS Search Engine Optimization Toolkit

by ScottGu at 09:53 AM, 06/03/2009

SEO (search engine optimization) is one of the important considerations that any Internet web-site needs to design with in mind.  A non-trivial percentage of Internet traffic to sites is driven by search engines, and good SEO techniques can help increase site traffic even further.

Likewise, small mistakes can significantly impact the search relevance of your site’s content and cause you to miss out on the traffic that you should be receiving.  Some of these mistakes include: multiple URLs on a site leading to the same content, broken links from a page, poorly chosen titles, descriptions, and keywords, large amounts of viewstate, invalid markup, etc.  These mistakes are often easy to fix - the challenge is how to discover and pinpoint them within a site.

Introducing the IIS Search Engine Optimization Toolkit

Today we are shipping the first beta of a new free tool - the IIS Search Engine Optimization Toolkit - that makes it easy to perform SEO analysis on your site and identify and fix issues within it.

You can install the IIS Search Engine Optimization Toolkit using the Microsoft Web Platform Installer I blogged about earlier this week.  You can install it through WebPI using the “install now” link on the IIS SEO Toolkit home

Once installed, you’ll find a new “Search Engine Optimization” section within the IIS 7 admin tool, and several SEO tools available within it:

The Robots and SiteMap tools enable you to easily create and manage robots.txt and sitemap.xml files for your site that help guide search engines on what URLs they should and shouldn’t crawl and follow.

The Site Analysis tool enables you to crawl a site like a search engine would, and then analyze the content using a variety of rules that help identify SEO, Accessibility, and Performance problems within it.

Using the IIS SEO Toolkit’s Site Analysis Tool

Let’s take a look at how we can use the Site Analysis tool to quickly review SEO issues with a site.  To avoid embarrassing anyone else by turning the tool loose on their site, I’ve decided to instead use the analysis tool on one of my own sites: www.scottgu.com.  This is a site I wrote many years ago (last update in 2005 I think).  If you install the IIS SEO Toolkit you can point it at my site and duplicate the steps below to drill into the SEO analysis of it.

Open the Site Analysis Tool

We’ll begin by launching the IIS Admin Tool (inetmgr) and clicking on the root node in the left-pane tree-view of the IIS7 admin tool (the machine name – in this case “Scottgu-PC”).  We’ll then select the “Site Analysis” icon within the Search Engine Optimization section on the right.  Opening the Site Analysis tool at the machine level like this will allow us to run the analysis tool against any remote server (if we had instead opened it with a site selected then we would only be able to run analysis against local sites on the box). 

Opening the Site Analysis tool causes the below screen to display – it lists any previously saved site analysis reports that we have created in the past.  Since this is the first time we’ve opened the tool, it is an empty list.  We’ll click the “New Analysis…” action link on the right-hand side of the admin tool to create a new analysis report:

Clicking the “New Analysis…” link brings up a dialog like below, which allows us to name the report as well as configure what site we want to crawl and how deep we want to examine it. 

We’ll name our new report “scottgu.com” and configure it to start with the http://www.scottgu.com URL and then crawl up to 10,000 pages within the site (note: if you don’t see a “Start URL” textbox in the dialog it is because you didn’t select the root machine node in the left-hand pane of the admin tool and instead opened it at the site level – cancel out, select the root machine node, and then click the Site Analysis link).

When we click the “Ok” button in the dialog above the Site Analysis tool will request the http://www.scottgu.com URL, examine the returned HTML content, and then crawl the site just like a search engine would.  My site has 407 different URLs on it, and it only took 13 seconds for the IIS SEO Toolkit to crawl all of them and perform analysis on the content that was downloaded. 

Once it is done it will open a report summary view detailing what it found.  Below you can see that it found 721 violations of various kinds within my site (ouch):

We can click on any of the items within the violations summary view to drill into details about them.  We’ll look into a few of them below.

Looking at the “description is missing” violations

You’ll notice above that I have 137 “The description is missing” violations.  Let’s double click on the rule to learn more about it and see details about the individual violations.  Double clicking the description rule above will open up a new query tab that automatically provides a filtered view of just the description violations (note: you can customize the query if you want – and optionally export it into Excel if you want to do even richer data analysis):

Double clicking any of the violations in the list above will open up details about it.  Each violation has details about what exactly the problem is, and recommended action on how to fix it:

Notice above that I forgot to add a <meta> description element to my photos page (along with all the other pages too).  Because my photos page just displays images right now, a search engine has no way of knowing what content is on it.  A 25 to 150 character long description would be able to explain that this URL is my photo album of pictures and provide much more context. 

The “Word Analysis” tab is often useful when coming up with description text.  This tab shows details about the page (its title, keywords, etc) and displays a list of all words used in the HTML within it – as well as how many times they are duplicated.  It also allows you to see all two-word and three-word phrases that are repeated on the page.  It also lists the <a> text used on other page to link to this page – all of which is useful to come up with a description:

Looking at the URL is linked using different casing violations

Let's now at the “URL is linked using different casing” violations.  We can do this by going back to our summary report page and by then clicking on this specific rule violation:

Search engines count the number of pages on the Internet that link to a URL, and use that number as part of the weighting algorithm they use to determine the relevancy of the content the URL exposes.  What this means is that if 1000 pages link to a URL that talks about a topic, search engines will assume the content on that URL has much higher relevance than a URL with the same topic content that only has 10 people linking to it.

A lot of people don’t realize that search engines are case sensitive, though, and treat differently cased URLs as different actual URLs.  That means that a link to /Photos.aspx and /photos.aspx will often be treated not as one URL by a search engine – but instead as two different URLs.  That means that if half of the incoming links go to /Photos.aspx and the other half go to /photos.aspx, then search engines will not credit the photos page as being as relevant as it actually is (instead it will be half as relevant – since its links are split up amongst the two).  Finding and fixing any place where we use differently cased URLs within our site is therefore really important.

If we click on the “URL is linked using different casing” violation above we’ll get a listing of all 104 URLs that are being used on the site with multiple capitalization casings:

Clicking on any of the URLs will pull up details about that specific violation and the multiple ways it is being cased on the site.  Notice below how it details both of the URLs it found on the site that differ simply by capitalization casing. In this case I am linking to this URL using a querystring parameter named "AlbumId".  Elsewhere on the site I am also linking to the URL using a querystring parameter named "albumid" (lower-case “a” and “i”).  Search engines will as a result treat these URLs as different, and so I won’t maximize the page ranking for the content:

Knowing there is a problem like this in a site is the first step. The second step is typically harder: trying to figure out all the different paths that have to be taken in order for this URL to be used like this.  Often you'll make a fix and assume that fixes everything - only to discover there was another path through the site that you weren't aware of that also causes the casing problem. To help with scenarios like this, you can click the "Actions" dropdown in the top-right of the violations dialog and select the "View Routes to this Page" link within it.

This will pull up a dialog that displays all of the steps the crawler took that led to the particular URL in question being executed. Below it is showing that it found two ways to reach this particular URL:

Being able to get details about the exact casing problems, as well as analyze the exact steps followed to reach a particular URL casing, makes it dramatically easier to fix these types of issues.

Looking at the page contains multiple canonical format violations

Fixing the casing issues like we did above is a good first step to improving page counts.  We also want to fix scenarios where the same content can be retrieved using URLs that differ by more than casing.  To do this we’ll return to our summary page and pull up the “page contains multiple canonical format violations” report:

Drilling into this report lists all of the URLs on our site that can be accessed in multiple “canonical” ways:

Clicking on any of them will pull up details about the issue. Notice below how the analysis tool has detected that sometimes we refer to the home page of the site as "/" and sometimes as "/Default.aspx". While our web-server will interpret both as executing the same page, search engines will treat them as two separate URLs - which means the search relevancy is not as high as it should be (since the weighting gets split up across two URLs instead of being combined as one).

We can see all of the cases where the /Default.aspx URL is being used by clicking on the “Links” tab above.  This shows all of the pages that link to the /Default.aspx URL, as well as all URLs that it in turn links to:

We can switch to see details about where and how the related “/” URL is being used by clicking the “Related URLs” drop-down above – this will show all other URLs that resolve to the same content, and allow us to quickly pull their details up as well:

Like we did with the casing violations, we can use the “View Routes to this Page” option to figure out of all the paths within the site that lead to these different URLs and use this to help us hunt down and change them so that we always use a common consistent URL to link to these pages. 

Note: Fixing the casing and canonicalization issues for all internal links within our site is a good first step.  External sites might also be linking to our URLs, though, and those will be harder to all get updated.  One way to fix our search ranking without requiring the externals to update their links is to download and install the IIS URL Rewrite module on our web server (it is available as a free download using the Microsoft Web Platform Installer).  We can then configure a URL Rewrite rule that automatically does a permanent redirect to the correct canonical URL – which will cause search engines to treat them as the same (read Carlos’ IIS7 and URL Rewrite: Make your Site SEO blog post to learn how to do this). 

Looking up redirect violations

As a last step let’s look at some redirect violations on the site:

Drilling into this rule category reminded me of something I did a few years ago (when i transferred my blog to a different site) - that I just discovered was apparently pretty dumb. 

When I first setup the site I had originally had a simple blog page at: www.scottgu.com/blog.aspx  After a few weeks, I decided to move my blog to weblogs.asp.net/scottgu.  Rather than go through all my pages and change the link to the new address, I thought I’d be clever and just update the blog.aspx page to do a server-side redirect to the new weblogs.asp.net/scottgu URL. 

This works from an end-user perspective, but what I didn’t realize until I ran the analysis tool today was that search engines are not able to follow the link.  The reason is because my blog.aspx page is doing a server-side redirect to the weblogs.asp.net/scottgu URL.  But for SEO reasons of its own, the blog software (Community Server) on weblogs.asp.net is in turn doing a second redirect to fix the incoming weblogs.asp.net/scottgu URL to instead be http://weblogs.asp.net/scottgu/ (note the trailing slash is being added).

According to the rule violation in the Site Analysis tool, search engines will give up when you perform two server redirects in a row. It detected that my blog.aspx redirect links to an external link that in turn does another redirect - at which point the search engine crawlers give up:

I was able to confirm this was the problem without having to open up the server code of the blog.aspx page. All I needed to-do was click the "Headers" tab within the violation dialog and see the redirect HTTP response that the blog.aspx page sent back. Notice it doesn't have a trailing slash (and so causes Community Server to do another redirect when it receives it):

Fixing this issue is easy. I never would have realized I actually had an issue, though, without the Site Analysis tool pointing me to it.

Future Automatic Correction Support

There are a bunch of additional violations and content issues that the Site Analysis tool identified when doing its crawl of my web-site.  Identifying and fixing them is straight-forward and very similar to the above steps.  Each issue I fix makes my site cleaner, easier to crawl, and helps it have even higher search relevancy.  This in turn will generate an increase of traffic coming to my site from search engines – which is a very cost effective return on investment.  Once a report is generated and saved, it will show up in the list of previous reports within the IIS admin tool.  You can at any point right-click it and tell the IIS SEO Toolkit to re-run it – allowing you to periodically validate that no regressions have been introduced.

The preview build of the Site Analysis tool today verifies about 50 rules when it crawls a site.  Over time we’ll add more rules that check for additional issues and scenarios.  In future preview releases you’ll also start to see even more intelligence built-into the SEO Analysis tool that will allow it to also verify on the server-side that you have the URL Rewrite module installed with a good set of SEO-friendly rules configured.  The Site Analysis tool will also allow you to fix certain violations automatically by suggesting rewrite rules that you can add to your site from directly within the site analysis report tool (for example: to fix issues like the “/” and “/Default.aspx” canonicalization issue we looked at before).  This will make it even easier to help enforce good SEO on the site.  Until then, I’d recommend reading these links to learn more about manually configuring URL Rewrite for SEO:

Summary

The IIS Search Engine Optimization Toolkit makes it easy to analyze and assess how search engine friendly your web-site is.  It pinpoints SEO violations, and provides instructions on how to fix them.  You can learn more about the toolkit and how to best take advantage of it from these links:

The IIS Search Engine Optimization Toolkit is free, takes less than a minute to install, and can be run against any existing web-server or web-site.  There is no need to install anything on a remote server to use it – just type in the URL of the site and you’ll get a report back a site analysis report with actionable items that that you can use immediately to improve it.

Today’s release is a beta release, so please use the IIS Search Engine Optimization Toolkit Forum to let us know if you run into any issues or have feature suggestions.

Hope this helps,

Scott 

 

Baby Toys via Facebook Connect

by Anatoly Lubarsky at 15:49 PM, 06/02/2009

I'd like to introduce Baby Toys application which is connected to Facebook via "Connect". Means that this version of Baby Toys is a standalone application while users need to have Facebook account in order to authorize on and use this application. See Chocolate Lovers app which has the same concept.



Still a kid at heart? Send baby toys to friends or put on your profile!


Baby Toys is available inside Facebook canvas as well — Baby Toys on Facebook.


On Baby Toys you are able to send toys to your friends on Facebook, attach toys to your Facebook profile and attach toys to your Facebook emails.


Enjoy :)

Microsoft Web Platform Installer

by ScottGu at 02:21 AM, 06/02/2009

One of the cool new releases coming out this year is a small download manager - the Microsoft Web Platform Installer - that makes installing and configuring web server and web development stacks really easy.  It is a free tool that you can download from the www.microsoft.com/web site (here is the direct link to the installer – choose the 2.0 version).  It works with Windows XP, Vista, Windows 7, Windows Server 2003 and Windows Server 2008.

The Web Platform Installer provides an easy way to quickly install and customize all the software you need to develop or deploy web sites and applications on a Windows machine.  The tool automatically analyses what your system currently has installed, allows you to easily mark additional components to be added, and then automates installing them all at once when you click the install button (saving you from having to manually install each one yourself). 

For example, you can click the “Web Server” section above to customize the individual IIS web server modules installed on the box.  This includes both the built-in IIS modules that ship with Windows (like the directory browsing module), as well as additional modules available as separate downloads.  Below I’ve selected two additional modules – the Application Request Routing and URL Rewrite modules – to be installed:

The URL Rewrite module is a free Microsoft module that enables you to publish custom URLs from your sites and optimize them for search engine optimization (SEO).  You can enforce SEO rules (consistent casing, embedded keywords, etc) and customize how your site looks from an external perspective however you want (the admin tool will even help guide you to write the regular expression rules):

The Application Request Routing is a free Microsoft module that supports forward-proxy style scenarios, and enables dynamic load-balancing of requests across multiple web-server machines (allowing you to scale out, move machines behind DMZ firewall scenarios, and bring machines in and out of a farm for maintenance without disruption). 

In addition to URL Rewrite and Application Request Routing, there are dozens of other web server modules you can select that enable WebDAV, Secure FTP, automated deployment, remote database management through the IIS admin tool for hosted scenarios, media server streaming scenarios, and more.  You can also install framework additions like ASP.NET MVC, .NET 3.5 SP1, SQL Express and associated SQL administration tools, Visual Web Developer 2008 Express, and more.

Windows Web Application Gallery

The web platform installer also integrates with the new Windows Web Application Gallery now online: www.microsoft.com/web/gallery 

This gallery allows you to easily install existing web applications onto your server.  The gallery contains a variety of popular .NET open source applications (like DotNetNuke, ScrewTurn Wiki and Umbraco CMS) as well as PHP open source applications (including WordPress and Drupal).  You can easily browse and install them using the Web Platform Installer as well (just click the “Web Applications” tab and check the applications you want to install):

;

In addition to downloading the application, the web platform installer will create a new site/application root and configure the appropriate site settings and optionally install the database.

Summary

If you haven’t downloaded the Web Platform Installer yet I’d recommend taking a look at it.  I think you’ll find it makes it much easier to configure and get a box up and running, and makes it much easier to find and install the various components of the Windows web server stack, as well as find and install applications to use on top of it.  Overtime you’ll see us ship more and more functionality this way. 

You can download and start using the Web Platform Installer 2.0 Beta today.  We’ll ship the final release of it this summer.

Hope this helps,

Scott

Here is the latest in my link-listing series.  Also check out my ASP.NET Tips, Tricks and Tutorials page and Silverlight Tutorials page for links to popular articles I've done myself in the past. 

You can also now follow me on twitter (@scottgu) where I also post links and small posts.

ASP.NET

AJAX

  • Automatically Minify and Combine JavaScript in Visual Studio: Dave Ward has a great article that describes how you can add a build command to Visual Studio that enables you to automatically compress and combine client-side JavaScript files.  This makes your pages load faster on the client and improves the perceived performance of your sites.

  • Client-side Data Binding in ASP.NET AJAX 4.0: Fritz Onion has a great article about the new client-side templating features of ASP.NET AJAX 4.0 (which you can download and use today in .NET 3.5 projects).  This enables powerful client data-binding scenarios against JSON based data.  Also check out Politian’s Blog to find some great tutorials on how to use it.

ASP.NET MVC

  • Visual Studio NUnit Templates for ASP.NET MVC: The VS Web Tools team has released updated NUnit templates that work with ASP.NET MVC 1.0.  This enables you to automatically create a test project that uses NUnit instead of MSTest when you do a File->New Project and select the ASP.NET MVC 1.0 Project item.

  • Custom Route Constraints in ASP.NET MVC: Keyvan Nayyeriu has a nice post that discusses how to create a custom route constraint in ASP.NET MVC (one of the extensibility points in Simone’s list above).  You can use these to control whether a route rule is used or not, and they can enable some pretty rich routing scenarios.  Note that in addition to creating route constraint classes, ASP.NET MVC also supports using Regular Expressions and HTTP Method filters to constrain routes as well. Keyvan is the co-author with Simone of the Beginning ASP.NET MVC Book (free chapter available).

Visual Studio

Hope this helps,

Scott

LIDNUG: Free Online Virtual Chat with Me Today

by ScottGu at 01:47 AM, 05/27/2009

LIDNUG (Linked .NET Users Group) is hosting an online chat with me today (Wednesday) from 11:30am to 1pm PST (Pacific Standard Time).  Anyone is free to join and the agenda topic will be open – so bring your questions!

Click here to learn more about how to register and attend it.

Hope to chat with you more then,

Scott

May 30th Update: If you missed the chat you can watch it online: http://www.lidnug.org/

Interview on MySpace app dev platform

by Anatoly Lubarsky at 14:34 PM, 05/17/2009

In April I gave a short interview to IDG sharing my opinion on MySpace dev. platform here:


MySpace app dev platform still a work in progress.


Participating: Gerardo Capiel, who was recently hired to be vice president of product management for the MySpace Open Platform, Gartner analyst Ray Valdes plus my 2 cents.


"Developing for MySpace is tough because the platform is still not stable; it has many issues and bugs which remain unfixed for months, Lubarsky said via e-mail. In its current state, the platform doesn't give enough confidence to developers."

My Opinion on Internet Explorer

by Anatoly Lubarsky at 08:46 AM, 05/06/2009

IE is still the most popular browser today.


IE7

IE7 is an absolute and utterly humiliating failure. It was very sad to see it fails over time taking into account that I'm usually a Microsoft fan when it comes to products and tools. It introduced some good usability features which already existed in FF but not in IE6 because IE6 development was frozen for quiet a while. The short list of features includes tabs, Ctrl-Enter, etc. The IE team should not have touched IE engine though. The browser became unstable and buggy. I use it only due to the fact that the majority of my users are on IE7.


IE8

IE8 is more solid than IE7 at a first glance. I installed it because Microsoft has moved it to the high priority updates last week. Too early. IE8 has many issues and I was forced to uninstall it. It needs service pack ASAP and I can't recommend to install it yet. In addition to some severe connectivity issues it causes many popular sites not to work properly with it. It has severe back compatibility issue.

Follow me on Twitter!

by Anatoly Lubarsky at 08:18 AM, 05/06/2009

Twitter got some hype recently because the site has become finally more stable and succeeded to reach some critical mass of valuable users/connectors. Many celebrities have joined Twitter recently. You can follow one of them here:


@anatoly


LOL

Chocolate Lovers via Facebook Connect

by Anatoly Lubarsky at 08:09 AM, 05/06/2009

I'd like to introduce Chocolate Lovers application which is connected to Facebook via "Connect". Means that this version of Chocolate Lovers is a standalone application while users need to have Facebook account in order to authorize on and use this application.



Love chocolate? Stick chocolate to your profile and send to friends!


On Chocolate Lovers users are able to send their favorite chocolates to their friends on Facebook, stick chocks to their Facebook profile, view their send/receive stats and even more.


Enjoy :)

Free ASP.NET MVC “NerdDinner” Tutorial Now in HTML

by ScottGu at 00:44 AM, 04/28/2009

Last month I blogged about a free end-to-end ASP.NET MVC tutorial called “NerdDinner” that I wrote for the Professional ASP.NET MVC 1.0 book from Wrox Press.  The book is now released and shipping on Amazon

The NerdDinner tutorial walks through how to build a small, but complete, application using ASP.NET MVC, and introduces some of the core concepts behind it.  You can download a PDF version of the tutorial here.

NerdDinner Tutorial Now Also Available in HTML

A few minutes ago I finished publishing an HTML version of the NerdDinner tutorial as well.  You can read it online for free here.

I split the tutorial up across 12 segments to make it more manageable to read.  I also increased the sizes of the screenshots, and used a really nifty syntax highlighter that Scott Hanselman helped set me up with.  I actually find the end result a lot easier to read than the PDF version.

Below are links to the different NerdDinner tutorial segments:

Hope this helps,

Scott

ASP.NET MVC 1.0

by ScottGu at 18:53 PM, 04/01/2009

mvcsource[1] Two weeks ago at MIX we released ASP.NET MVC 1.0.  ASP.NET MVC is a free, fully supported, Microsoft product that enables developers to easily build web applications using a model-view-controller pattern.  ASP.NET MVC provides a “closer to the metal” web programming option for ASP.NET.  It enables full control over HTML markup and URL structure, and facilitates unit testing and a test driven development workflow.

Releasing the ASP.NET MVC source code under MS-PL

I’m excited today to announce that we are also releasing the ASP.NET MVC source code under the Microsoft Public License (MS-PL).  MS-PL is an OSI-approved open source license.  The MS-PL contains no platform restrictions and provides broad rights to modify and redistribute the source code.  You can read the text of the MS-PL at: http://www.opensource.org/licenses/ms-pl.html

Learning more about ASP.NET MVC

To learn more about ASP.NET MVC, you can read my free ASP.NET MVC PDF tutorial that covers building an end-to-end application (starting literally with File->New Project).

There were a number of great ASP.NET MVC talks at MIX this year.  Below are links to several of them:

There are also several great ASP.NET MVC tutorials at http://www.asp.net/mvc.  You can also read the ASP.NET MVC MSDN Documentation.

Download ASP.NET MVC

Click here to download and install ASP.NET MVC 1.0.  You can also install it using the new Microsoft Web Platform Installer V2 – which provides an integrated setup experience for the entire Microsoft web stack.

The ASP.NET MVC 1.0 source code is now available.  Scroll down to the bottom of the ASP.NET MVC download page and you’ll find links to both the ASP.NET MVC 1.0 integrated MSI setup, as well as a .zip file that contains the ASP.NET MVC source code.  The ASP.NET MVC source code includes a VS 2008 project file that enables you to build it.

Hope this helps,

Scott

MIX 09

by ScottGu at 23:37 PM, 03/31/2009

Two weeks ago we held our MIX conference in Las Vegas.  MIX is my favorite conference of the year – since it nicely integrates development and design topics together in a single event, and is usually accompanied by some pretty cool product announcements.

I gave a first day MIX keynote again this year, and in it I talked about and announced a bunch of new Microsoft web development products.  These included:

My keynote also included a ton of demos and highlighted a bunch of great customers including: StackOverflow, NetFlix, NBC, Bondi Publishing, and KEXP.

Click here to watch the day one MIX keynote online.  Bill Buxton led off the keynote with a great talk about user experience for 20 minutes – I then talked for an hour and 50 minutes after him.

You can also watch all the breakout sessions from MIX online for free here (Greg Duncan has an easy to navigate list of them here as well).

I’ll be doing more in-depth blog posts in the days ahead on many of the technologies we introduced/announced and all the cool things you can do with them. 

Hope this helps,

Scott

Free ASP.NET MVC eBook Tutorial

by ScottGu at 14:54 PM, 03/10/2009

bookcover[1] There has been a lot of excitement in the community about the new ASP.NET MVC framework that is about to ship (literally any day now – announcement coming soon).  As with anything new, people are also asking for more tutorials/samples/documentation that cover how to get started and build applications with it.

Over the last few months I’ve been helping to contribute to an ASP.NET MVC book that Scott Hanselman, Rob Conery, and Phil Haack have been writing for Wrox.  The book is now in production, and will be available to buy in stores soon (you can pre-order it on Amazon today).

I wrote the first chapter of the book – which is a 185 page end-to-end tutorial that walks-through building a small, but complete, ASP.NET MVC application from scratch.  The agreement I made with Wrox was that I’d write it for free in return for them also making it available as a free PDF download.

I’m excited to announce that you can now download this free end-to-end tutorial chapter (it is a 14mb PDF file). It’s licensed under a “Creative Commons Attribution No Derivatives” license – which means you can share, distribute, print, or hand it out to anyone.

NerdDinner ASP.NET MVC Tutorial

The tutorial starts by using the File->New Project command in Visual Studio to create a brand new ASP.NET MVC project, and then incrementally adds functionality and features.  Along the way it covers how to:

  • Create a database
  • Build a model with validation and business rules
  • Implement data listing/details UI on a site using Controllers and Views
  • Enable CRUD (Create, Update, Delete) data form entry
  • Use the ViewModel pattern to pass information from a Controller to a View
  • Re-use UI across a site using partials and master pages
  • Implement efficient data paging
  • Secure an application using authentication and authorization
  • Use AJAX to deliver dynamic updates
  • Use AJAX to add interactive map support
  • Perform automated unit testing (including dependency injection and mocking)

The application the tutorial builds is called “NerdDinner”. It provides an easy way for people to organize, host and search for new topic-based dinners online:

nerddinner_small[1]

Scott Hanselman has been hosting NerdDinners for years, and came up with the idea of building the tutorial around an application that facilitates this.  He is also now hosting a live custom-skinned version of the application at www.nerddinner.com)

Download Links

Hope this helps,

Scott

P.S. The book is entering production now and so is officially in un-edited status (meaning professional editors haven’t gone through it yet).  We’ll update the PDF with any important edits once the text is final.

P.P.S. And yes – this is one of the reasons my blog has been more quiet than normal the last few months.  Expect more regular blog posting again soon once I recover from this. :-)

Moonlight 1.0 Release

by ScottGu at 17:27 PM, 02/11/2009

I am excited to announce that Novell today released version 1.0 of Moonlight, and is making it available for download at no cost with support for most major Linux distro’s (including openSUSE, SUSE Linux Enterprise, Fedora, Red Hat, and Ubuntu). For those unfamiliar with it, Moonlight is a joint effort between Novell and Microsoft of an open-source implementation of Silverlight for Linux.

My team has worked closely with Miguel de Icaza and his team on the project.  We are also shipping the Microsoft Media Pack – which is a set of licensed media codecs that enable playback for all Silverlight compatible media (wmv, wma, mp3, etc.), as a free download for Linux users who run Moonlight.

Moonlight enables Linux users to view Silverlight content and Silverlight applications.  Recently the official Presidential Inauguration Committee broadcast the inauguration of President Barack Obama using Silverlight.  Over 50,000 viewers using Linux installed Moonlight and watched the event live using it.  Miguel de Icaza and the volunteers behind Moonlight made a tremendous effort to make sure that Linux users were able to watch the broadcast of the inauguration, even though the official release of Moonlight was still a few weeks away.

image

I am really excited about the awesome work Miguel and his team at Novell have done, and we’re looking forward to seeing Moonlight 2 (a Silverlight 2 compatible implementation with .NET support) which the team is hard at work on. For more details on the Moonlight 1.0 release, check out Miguel’s blog post on it.

Thanks,

Scott

ASP.NET MVC 1.0 Release Candidate Now Available

by ScottGu at 12:13 PM, 01/27/2009

Today we shipped the ASP.NET MVC 1.0 Release Candidate (RC).  Click here to download it (note: the link just went live so if it isn’t working wait a few minutes for the server you are hitting to refresh).  It works with both Visual Studio 2008 and Visual Web Developer 2008 (which is free).

Today’s RC is the last public release of ASP.NET MVC that we’ll ship prior to the final “1.0” release.  We expect to ship the final ASP.NET MVC 1.0 release next month.

In addition to bug fixes, today’s build includes several new features.  It also includes some refinements to existing features based on customer feedback.  Please read the release notes that ship with the ASP.NET MVC download for full details on all changes.  The release notes include detailed instructions on how to upgrade existing applications built with the ASP.NET MVC Beta to the RC.

Visual Studio Tooling Improvements

The RC includes several new Visual Studio tooling features (above and beyond the existing support in the beta – which I won’t cover here).  These features include:

Add Controller Command

You can now type Ctrl-M, Ctrl-C within an ASP.NET MVC project, or right-click on the /Controller folder and choose the “Add->Controller” context menu item to create new controller classes:

This will cause an “Add Controller” dialog to appear that allows you to name the Controller to create, as well as optionally indicate whether you wish to automatically “scaffold” common CRUD methods:

Clicking the “Add” button will cause the controller class to be created and added to the project:

Add View Command

You can now type Ctrl-M, Ctrl-V within a Controller action method, or right-click within an action method and choose the “Add View” context menu item to create new view templates:

This will cause an “Add View” dialog to appear that allows you to name and create a new view (it is pre-populated with convention-based options).  It allows you to create “empty” view templates, or automatically generate/scaffold view templates that are based on the type of object passed to the view by the Controller action method.  The scaffolding infrastructure uses reflection when creating view templates – so it can scaffold new templates based on any POCO (plain old CLR object) passed to it.  It does not have a dependency on any particular ORM or data implementation.

For example, below we are indicating that we want to scaffold a “List” view template based on the sequence of Product objects we are passing from our action method above:

Clicking the “Add” button will cause a view template to be created for us within the \Views\Products\ directory with a default “scaffold” implementation:

We can then run our application and request the /products URL within our browser to see a listing of our retrieved products:

The RC ships with a number of built-in scaffold templates: “Empty”, “List”, “Details”, “Edit” and “Create” (you can also add your own scaffold templates – more details on this in a moment). 

For example, to enable product editing support we can implement the HTTP-GET version of our “Edit” action method on our Products controller like below and then invoke the “Add View” command:

Within the “Add View” dialog we can indicate we are passing a “Product” object to our view and choose the “Edit” template option to scaffold it:

Clicking the “Add” button will cause an edit view template to be created with a default scaffold implementation within the \Views\Products\ directory:

We can then run our application and request the /products/edit/1 URL within our browser to edit the Product details:

To save edit changes we can implement the HTTP-POST version of our “Edit” action method on our Products controller:

Notice in the code above how in the case of an error (for example: someone enters a bogus string for a number value) we redisplay the view.  The “edit” and “create” scaffold templates contain the HTML validation helper methods necessary to preserve user input and flag invalid input elements in red when this happens:

You’ll rarely end up using a scaffold-created template exactly as-is, and often will end up completely replacing it.  But being able to get an initial implementation up and running quickly, and having an initial view template for your scenario that you can then easily tweak is really useful.

Because the scaffold infrastructure supports scaffolding views against any plain-old CLR object, you can use it with both domain model objects (including those mapped with LINQ to SQL, LINQ to Entities, nHibernate, LLBLGen Pro, SubSonic, and other popular ORM implementations) as well as to create scaffolds with custom Presentation Model/ViewModel classes.

Adding and Customizing Scaffold Templates

ASP.NET MVC’s scaffolding infrastructure is implemented using Visual Studio’s built-in T4 templating architecture (Scott Hanselman has a nice blog post on T4 here). 

You can customize/override any of the built-in ASP.NET MVC scaffold template implementations.  You can also create additional scaffold templates (for example: the “ScottGu Crazy Look” scaffold option) and have them be displayed as options within the “Add View” dialog.

To customize/add scaffold templates at the machine-wide level, open the “C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\Web\MVC\CodeTemplates” folder:

The “AddController” sub-folder contains the scaffold template for the “Add Controller” dialog.  The “AddView” sub-folder contains the scaffold templates for the “Add View” dialog:

The scaffold templates populated within the “Add View” dialog are simply text files that have the “.tt” file-name extension.  These “.tt” text files contain inline C# or VB code that executes when the template is selected. 

You can open and edit any of the existing files to customize the default scaffolding behavior.  You can also add new “.tt” template files – like I have above with the “Scott Crazy Look.tt” file.  When you add a new template file the “Add View” dialog will be updated to automatically include it in the list of available scaffold options:

In addition to customizing/adding template files at the machine level, you can also add/override them at the individual project level.  This also enables you to check-in the templates under source control and easily use them across a team.

You can customize the scaffold templates at a project level by adding a “CodeTemplates” folder underneath your project.  You can then have “AddController” and “AddView” sub-folders within it:

You can override any of the default machine-wide templates simply be adding a “.tt” file with the same name to the project.  For example, above we are overriding the default “Controller.tt” scaffold template used in “Add Controller” scenarios. 

You can add new view-template scaffold files to the list by placing them within the “AddView” folder.  For example, above we added a “Yet Another Crazy Look.tt” view template to our project.  When we use the “Add View” dialog we’ll now see a union of the templates defined at the machine and project level:

Note: When you add “.tt” templates under the \CodeTemplates folder make sure to set the “Custom Tool” property of each of the “.tt” template files to an empty string value within the property grid (otherwise you’ll get an error trying to run it).  You might also need to close and reopen the project to clear a spurious error from the error list.  We’ll be publishing more blog posts that cover creating/customizing scaffolding templates shortly.

Go To Controller / Go To View

The RC build now supports the ability to quickly navigate between the Controllers and Views within your projects. 

When your cursor is within a Controller action method you can type Ctrl-M, Ctrl-G to quickly navigate to its corresponding view template.  You can also perform this same navigation jump by right-clicking within the action method and selecting the “Go To View” menu option:

In the example above we used the “Go To View” command within the “Edit” action method of the ProductsController class.  This will cause the \Views\Products\Edit.aspx view template to be opened and have the default focus within VS:

Within view templates you can also now type Ctrl-M, Ctrl-G to quickly navigate to the view’s corresponding Controller class.  You can also perform this navigation jump by right-clicking within the view template and selecting the “Go To Controller” menu option:

MSBuild Task for Compiling Views

By default when you do a build on an ASP.NET MVC project it compiles all code within the project, except for the code within view template files.  With the ASP.NET MVC Beta you had to roll your own MSBuild task if you wanted to compile the code within view templates.  The ASP.NET MVC RC build now includes a built-in MSBuild task that you can use to include views as part of the project compilation process.  This will verify the syntax and code included inline within all views, master pages, and partial views for the application, and give you build errors if it encounters any problems.

For performance reasons we don't recommend running this for quick compiles during development, but it is convenient to add to particular build configuration profiles (for example: staging and deployment) and/or for use with Build or CI (continuous integration) servers.  Please review the release notes for the steps to enable this.

View Refactoring Support

The names of the files and folders under the \Views application sub-folder will now automatically be updated when you perform controller class rename or action method rename using the “Rename” refactoring command in VS 2008.  VS 2008 will apply the standard convention-based naming pattern to existing view files/folders when the Controller class is updated.

View Improvements

The RC build includes a number of view-specific enhancements that were incorporated based on feedback during the preview releases.

Views without Code-Behind Files

Based on feedback we’ve changed view-templates to not have a code-behind file by default.  This change helps reinforce the purpose of views in a MVC application (which are intended to be purely about rendering and to not contain any non-rendering related code), and for most people eliminates unused files in the project.

The RC build now adds C# and VB syntax support for inheriting view templates from base classes that use generics.  For example, below we are using this with the Edit.aspx view template – whose “inherits” attribute derives from the ViewPage<Product> type:

One nice benefit of not using a code-behind file is that you'll now get immediate intellisense within view template files when you add them to the project.  With previous builds you had to do a build/compile immediately after creating a view in order to get code intellisense within it.  The RC makes the workflow of adding and immediately editing a view compile-free and much more seamless.

Important: If you are upgrading a ASP.NET MVC project that was created with an earlier build make sure to follow the steps in the release notes – the web.config file under the \Views directory needs to be updated with some settings in order for the above generics based syntax to work.

Model Property

With previous builds of ASP.NET MVC, you accessed the strongly typed model object passed to the view using the ViewData.Model property:

The above syntax still works, although now there is also a top-level "Model" property on ViewPage that you can also use:

This property does the same thing as the previous code sample - its main benefit is that it allows you to write the code a little more concisely.  It also allows you to avoid using the ViewData dictionary in cases where you want the view template to only interact with the strongly-typed model passed to it.

Setting the Title

The default master-page template added to new ASP.NET MVC projects now has an <asp:contentplaceholder/> element within its <head> section.  This makes it much easier for view templates to control the <title> element of the HTML page rendered back – and not require the Controller to explicitly pass a “title” parameter to configure it (which was the default with previous ASP.NET MVC builds and we thought questionable from a responsibilities perspective). 

For example, to customize the <title> of our Edit view to include the current product name we can now add the below code to our Edit.aspx template to drive the title directly off of the model object being passed the view:

The above code will then cause the browser to render the title using the Product name at runtime:

In addition to setting the <title> element, you can also use the above approach to dynamically add other <head> elements at runtime.  Another common scenario this is useful with is configuring model/view specific <meta/> elements for search engine optimization. 

Strongly Typed HTML/AJAX Helpers

One of the requests a few people have asked for is the ability to use strongly-typed expression syntax (instead of strings) when referring to the Model when using a View's HTML and AJAX helper objects.

With the beta build of ASP.NET MVC this wasn't possible, since the HtmlHelper and AjaxHelper helper classes didn't expose the model type in their signature, and so people had to build helper methods directly off of the ViewPage<TModel> base class in order to achieve this. 

The ASP.NET MVC RC build introduces new HtmlHelper<TModel> and AjaxHelper<TModel> types that are exposed on the ViewPage<TModel> base class.  These types now allow anyone to build strongly-typed HTML and AJAX helper extensions that use expression syntax to refer to the View's model.  For example:

The HTML form helper extension methods in the core ASP.NET MVC V1 assembly still use the non-expression based string syntax.  The “MVC Futures” assembly released today (which works with the RC) has a few initial implementations of expression-syntax based form helper methods.   We are going to iterate on these a bit longer and then consider adding them into the ASP.NET MVC core assembly in the next release. 

You can of course also add your own helper methods (using either strings or strongly-typed expressions).  The built-in HTML/AJAX helper methods can also optionally be removed (because they are extension methods) if you want to replace or override them with your own

Form Post Improvements

The RC build includes a number of form-post specific enhancements:

[Bind(Prefix=””)] No Longer Required for Common Scenarios

The RC build no longer requires you to explicitly use a [Bind] attribute (or set its prefix value to “”) in order to map incoming form post parameters that do not have a prefix to complex action method parameters.

To see what this means, let’s implement the “Create” scenario for our ProductsController.  We’ll begin by implementing the HTTP-GET version of our “Create” action method.  We’ll do this with code below that returns a View based on an empty Product object:

We can then right-click within our action method, choose the “Add View” command and scaffold a “create” view template that is based on a Product:

Notice above how our Html.TextBox() helper methods are referencing the “ProductName” and “SupplierID” properties on our Product object.  This will generate HTML markup like below where the input “name” attributes are “ProductName” and “SupplierID”:

We can then implement the HTTP-POST version of our “Create” action method. We’ll have our action method take a Product object as a method parameter:

With the ASP.NET MVC Beta we would have had to add a [Bind(Prefix=””)] attribute in front of our Product argument above – otherwise the ASP.NET MVC binding infrastructure would have only looked for form post values with a “productToCreate.” prefix (for example: productToCreate.ProductName and productToCreate.SupplierID) and not found the submitted values from our form (which don’t have a prefix). 

With the RC build, the default action method binders still first attempt to map a productToCreate.ProductName form value to the Product object.  If they don’t find such a value, though, they now also attempt to map “ProductName” to the Product object.  This makes scenarios where you pass in complex objects to an action method syntactically cleaner and less verbose.  You can take advantage of this feature both when mapping domain objects (like our Product object above) as well as with Presentation Model/ViewModel classes (like a ProductViewModel class).

A completed implementation of our Create action method (including basic input type error handling) might look like below:

Now our create action will save the Product object if all values are entered correctly.  When a user attempts to create a Product with invalid Product property values (for example: a string “Bogus” instead of a valid Decimal value), the form will redisplay and flag the invalid input elements in red:

ModelBinder API Improvements

The model binding infrastructure within the ASP.NET MVC Release Candidate has been refactored to add additional extensibility points to enable custom binding and validation schemes.  You can read more about these details in the ASP.NET MVC RC release notes.

Model Binders can also now be registered for interfaces in addition to classes. 

IDataErrorInfo Support

The default model binder with ASP.NET MVC now supports classes that implement the IDataErrorInfo interface.  This enables a common approach to raise validation error messages in a way that can be shared across Windows Forms, WPF and now ASP.NET MVC applications.

Unit Testing Improvements

The ASP.NET MVC RC includes some significant improvements to unit testing:

ControllerContext changed to no longer derive from RequestContext

The RC build includes a refactoring of the ControllerContext class that significantly simplifies common unit testing scenarios.  The ControllerContext class no longer derives from RequestContext and now instead encapsulates RequestContext and exposes it as a property.  The properties of ControllerContext and its derived types are also now virtual instead of sealed – making it significantly easier to create mock objects.

To see how this helps, let’s consider an action method like below that uses both the “Request” and “User” intrinsic objects:

Testing the above action method with previous ASP.NET MVC builds would have required mocking RequestContext and ControllerContext (with some non-obvious constructors that also brought in a RouteData object).

With the RC build we can now unit test it like below (using Moq to mock a ControllerContext for our Controller that allows us to simulate the Request.IsAuthenticated and User.Identity.Name properties):

The refactoring improvements made help out not just with testing Controller actions – but also help with testing filters, routes, custom actionresult types, and a variety of other scenarios.

AccountsController Unit Tests

The ASP.NET MVC Project Template included with the RC build now adds 25 pre-built unit tests that verify the behavior of the AccountsController class (which is a controller added to the project by default to handle login and account management scenarios).  This makes refactoring/updating AccountsController easier.  The AccountsController implementation has also been modified to more easily enable non-Membership Provider based credential systems to be integrated.

Cross Site Request Forgery (CSRF) Protection

Cross-site request forgery (CSRF) attacks (also referred to as XSRF attacks) cause users of a trusted browser agent to take unintended actions on a site.  These attacks rely on the fact that a user might still be logged in to another site.  A malicious Web site exploits this by creating a request to the original site (for example: by linking to a URL on the site using a <img src=””/> element on the hacker site). The request is made using the user’s browser and thus with the user’s authentication token and credentials. The attacker hopes that the user’s authentication or session cookie is still valid and if so, the attacker can sometimes take disruptive action.  You can learn more about this hacking technique here.

The ASP.NET MVC RC now includes some built-in CSRF protection helpers that can help mitigate CSRF attacks.  For example, you can now use the Html.AntiForgeryToken() helper to render a hidden input token within forms:

This helper issues a HTTP cookie and renders a hidden input element into our form.  Malicious web-sites will not be able to access both values.

We can then apply a new [ValidateAntiForgeryToken] attribute onto any action method we want to protect:

This will check for the existence of the appropriate tokens, and prevent our HTTP-POST action method from running if they don’t match (reducing the chance of a successful CSRF attack).

File Handling Improvements

The ASP.NET MVC RC includes a number of file handling enhancements:

FileResult and File() helper method

The RC build adds a new FileResult class that is used to indicate that a file is being returned as an ActionResult from a Controller action method.  The Controller base class also now has a set of File() helper methods that make it easy to create and return a FileResult.

For example, let’s assume we are trying to build a photo management site.  We could define a simple “Photo” class like below that encapsulates the details about a stored Photo:

We could then use the new File() helper method like below to implement a “DisplayPhoto” action method on a PhotoManager controller that could be used to render the Photo out of a database store.  In the code below we are passing the File() helper the bytes to render, as well as the mime-type of the file. If we pointed a <img src=””/> element at our action method URL the browser would display the photo inline within a page:

If we wanted an end-user to be able to download the photo and save it locally, we could implement a “DownloadPhoto” action method like below.  In the code below we are passing a third parameter – which will cause ASP.NET MVC to set a header that causes the browser to display a “Save As…” dialog which is pre-populated with the filename we’ve supplied:

When a user clicks a link to the /PhotoManager/DowloadPhoto/1232 URL they’ll be prompted to save the picture:

File Uploading Support

The RC build also includes built-in model-binder support for uploaded files and multi-part mime content. 

For example, we could have a <form> whose enctype attribute is set to “multipart/form-data” perform a post to the /PhotoManager/UploadPhoto URL.  If a <input type=”file” name=”fileToUpload”/> element was within the form it would cause the file selected by the end-user to be passed to our action method as an HttpPostedFileBase object:

We could then use the HttpPostedFileBase object to get access to the raw bytes of the uploaded file, its mime-type, and optionally save it to a database or disk.

AJAX Improvements

The ASP.NET MVC RC includes a number of AJAX enhancements:

jQuery Intellisense Files included within ASP.NET MVC Project Template

Newly created ASP.NET MVC projects now include both the standard jQuery library (both full and compressed versions), as well as the –vsdoc intellisense documentation file used by Visual Studio to provide richer intellisense support for it (you can learn more about this here):

This enables rich jQuery JavaScript intellisense within client-script blocks and JavaScript files:

Today’s RC build ships jQuery 1.2.6.  We are planning to ship the upcoming jQuery 1.3.1 release for the final ASP.NET MVC 1.0 release, and will include an updated JavaScript intellisense file for it. 

Request.IsAjaxRequest Property

The Request.IsAjaxRequest property can be used to detect whether a request is being sent from an AJAX call on the client (and is useful for scenarios where you want to gracefully degrade if AJAX is not enabled).  The logic within this method was updated with the RC to now recognize the “X-Requested-With” HTTP header (in addition to the form field sent by ASP.NET AJAX).  This is a well known header sent by JavaScript libraries such a Prototype, jQuery, and Dojo – and now enables a unified way to check for AJAX within an ASP.NET MVC request. 

JavaScriptResult ActionResult and JavaScript() helper method

The Controller base class now has a JavaScript() helper method that returns a new ActionResult class of type JavaScriptResult.  This supports the ability to return raw JavaScript that will then be executed on the client by the built-in ASP.NET MVC helper methods.  This can be useful for scenarios where you want to cause conditional JavaScript to execute on the client based on server logic.

Summary

We are pretty excited to be in the final “home stretch” of ASP.NET MVC V1.  Please report any issues you find with the RC build as soon as possible so that we can get them resolved for the final release.  The team plans to carefully monitor feedback over the next few weeks, and assuming no big issues come up ship the official V1 build next month.

Hope this helps,

Scott

Silverlight and the 2009 Presidential Inauguration

by ScottGu at 12:21 PM, 01/19/2009

Tomorrow’s presidential inauguration of Barack Obama will be a truly historic event.

Silverlight is being used as an enabling technology on several sites that will allow those of us who can’t be there in person to share the experience online.

Presidential Inaugural Committee

The Presidential Inaugural Committee has worked with iStreamPlanet to enable live and live and on-demand video streaming of the Inauguration events at the official Presidential Inaugural Committee web site: www.pic2009.org. It streamed its first live video on Saturday, with the train ride that took President-elect Obama from Philadelphia to Washington, D.C. The official Inaugural swearing-in ceremony, speeches and parade will also be streamed live online on Tuesday, January 20.

 

You can read more about the Presidential Inaugural Committee here.

Update: The site was viewable not just on Windows and Mac systems with Silverlight, but also on Linux systems using Moonlight (the Linux version of Silverlight built by Novell),  You can learn more about the Linux support here.

CNN and MSNBC with Photosynth

CNN and MSNBC are both launching Photosynth viewers that will help capture the Oath of Office experience. They will combine pictures takes from professional photographers with pictures uploaded from people in the crowd to create an interactive Photosynth experience of the event using Silverlight’s built-in DeepZoom feature to deliver an amazing 3D viewing of it.

Check out CNN’s and MSNBC’s pages a few hours after viewers send in their pictures of the inauguration crowd, the President-elect’s raised hand, and everything in between.

You can learn more about Photosynth and Silverlight from the Photosynth team blog here.

CBS Television Stations

CBS Television Stations will be leveraging Silverlight and Move Networks’ streaming services to deliver a live HD streaming experience (up to 2.4 Mpbs) for online viewers. CBS will roll out the experience to a number of major market stations including: Chicago, Los Angeles, Denver and New York. Visitors to the CBS sites will be able to watch a variety of inaugural activities, with up to seven camera feeds for live events, as well as reports from CBS reporters on site, and real-time Twitter integration.

You can watch the CBS experience here.

This week will be an exciting part of history.  Hope you get a chance to enjoy experiencing it with Silverlight!

Scott

Today we launched a new ASP.NET MVC Design Gallery on the www.asp.net site.  The design gallery hosts free HTML design templates that you can download and easily use with your ASP.NET MVC applications.  Included with each design template is a Site.master file, a CSS stylesheet, and optionally a set of images, partials, and helper methods that support them. 

The gallery allows you to preview each of the designs online, as well as download a .zip version of them that you can extract and integrate into your site.  The gallery allows anyone to create and submit new designs under the creative commons license.  Visitors to the gallery can vote to provide feedback on them (thumbs up/thumbs down).  The most popular designs show up at the top of the gallery. 

We think this will provide a useful way for developers to more easily create attractive, standards compliant, sites.  It will also hopefully encourage folks to create and share designs that can be easily re-used by others.

Upcoming View Improvements with the Release Candidate

While on the topic of UI, I thought I'd also share a few details about some of the View-related improvements that are coming with the new ASP.NET MVC Release Candidate (RC) build that will be shipping shortly.  In addition to bug fixes, the release candidate incorporates a number of view-specific feature additions and community suggestions.

Views without Code-Behind Files

Based on feedback from a lot of people, we've decided to make a change so that MVC view files by default do not have code-behind files. This change helps to reinforce the purpose of views in a MVC world (which are intended to be purely about rendering and to not contain any non-rendering related code), and for most people eliminates unused files in the project:

With the ASP.NET MVC Beta, developers could eliminate the code-behind file by using the CLR syntax for generic types in a view's inherits attribute, but that CLR syntax is (to put it mildly) pretty undiscoverable and hard to use.  The ASP.NET MVC team was able to combine a few extensibility features already in ASP.NET to now enable the standard VB/C# language syntax within the inherits attribute with the ASP.NET RC build:

One other nice benefit of not using a code-behind file is that you'll now get immediate intellisense when you first add them to the project.  With the beta you had to do a build/compile immediately after creating a view in order to get code intellisense within it.  The RC makes the workflow of adding and immediately editing a view compile-free and much more seamless.

Top-Level Model Property on Views

With previous builds of ASP.NET MVC, you accessed the strongly typed model object passed to the view using the ViewData.Model property:

The above syntax still works, although now there is also a top-level "Model" property on ViewPage that you can use:

This property does the same thing as the previous code sample - its main benefit is that it allows you to write the code a little more concisely.

HTML/AJAX Helpers Now Enable Expression Syntax

One of the requests a few people have asked for is the ability to use strongly-typed expression syntax (instead of using strings) when referring to the Model when using a View's HTML and AJAX helper objects.

With the beta build of ASP.NET MVC this wasn't possible, since the HtmlHelper and AjaxHelper helper classes didn't expose the model type in their signature, and so people had to build helper methods directly off of the ViewPage<TModel> base class in order to achieve this.  The ASP.NET MVC RC build introduces new HtmlHelper<TModel> and AjaxHelper<TModel> types that are exposed on the ViewPage<TModel> base class.  These types now allow anyone to build strongly-typed HTML and AJAX helper extensions that use expression syntax to refer to the View's model.

For example, I could build a (very simple) strongly-typed "TextBox" helper method using the code below:

And then use it within any of my views to bind against a Product model object like so:

Visual Studio will provide full intellisense for the strongly-typed expression syntax when working against the View's model in the source editor in this way:

 

Note: the HTML helper extensions in the core ASP.NET MVC V1 assembly will still use the existing (non-expression based) syntax.  We are then planning to add expression-based versions to the MVCFutures assembly. You can of course also add your own helper methods (using either strings or strongly-typed expressions).  All of the built-in helper methods can also optionally be removed (because they are extension methods) if you want to replace or override them with your own.

Scaffolding Support

The ASP.NET MVC RC build includes automatic "UI scaffolding" support when creating views using the new ASP.NET MVC "Add View" command inside Visual Studio.  The scaffolding support enables the automatic generation of views against any .NET type or object - meaning it can work against POCO classes, LINQ to SQL, LINQ to Entities, NHibernate, SubSonic, LLBLGen Pro, or any other object model. The scaffolding engine uses reflection to retrieve the public shape of a View's model type, and then passes it to a scaffolding template to populate appropriate markup based on it within the view being created.

For example, assume we have a ProductsController class and want to create an "Edit" action on it to display an edit view of a particular Product.  Using the RC build we can right-click within our "Edit" action method and choose the "Add View" context menu command like so:

Within the "Add View" dialog we can then indicate that we are passing a "Product" type to our View:

We can indicate that we want an "Empty" view template created (like above), or indicate that we want VS to automatically scaffold a form "Edit" view for the Product object we are supplying:

If we choose the "Edit" template VS will automatically generate a file for us that has the appropriate HTML and validation helpers to create an editable form view:

We can then run the application and immediately get edit UI:

We can then go in and change the generated edit.aspx file however we want to tweak/customize it. 

One of the really nice things about the scaffolding system we are shipping is that it is implemented using Visual Studio's built-in T4 code generation system (Scott Hanselman has a nice post about this here).  The "List", "Edit", "Create" and "Details" templates we ship with ASP.NET MVC can all be completely customized or replaced with T4 templates of your own (or downloaded from the ASP.NET MVC Design Gallery). So if you have your own particular way of creating HTML, or want to use custom HTML helpers (for example: strongly-typed expression based ones) you can update the default templates and the scaffolding system will use them going forward. 

We are planning to enable the templates to be overriden both on a machine-wide level, as well as on a per-project level (so that you can check-in application-specific scaffolding templates under source control and share them across a team).

MSBuild Task for Compiling Views

By default when you do a build on an ASP.NET MVC project it compiles all code within the project, except for the code within view files.  With the ASP.NET MVC Beta you had to roll your own MSBuild task if you wanted to compile the views.  The ASP.NET MVC RC build now includes a built-in MSBuild task that you can use to include views as part of the project compilation process.  This will verify the syntax and code included inline within all views and master pages for the application, and give you build errors if it encounters any problems.

For performance reasons we don't recommend running this for quick compiles during development, but it is convenient to add to particular build configuration profiles (for example: staging and deployment) and/or for use with Build or CI (continuous integration) servers.

Other ASP.NET MVC Release Candidate features coming

Above is a short list of some of the view-specific functionality coming with the release candidate build. 

There are many other features and requests coming with the RC as well including: IDataErrorInfo support to enable models to surface validation error messages, as well as richer error validation extensibility to enable you to use your own approach to surface model validation errors to ModelBinders (the IDataErrorInfo support is built on top of this); new FileResult and JavaScriptResult ActionResult types (allowing you to more easily download files as well as executable JavaScript to browsers); built-in jQuery -vsdoc intellisense support; refactored AccontController support to enable easier unit testing and extensibility with form login scenarios; a variety of project template improvements, more extensibility everywhere; lots of bug fixes; and a few other cool features I'll blog about later once the RC is out.

We'll be releasing the ASP.NET MVC Release Candidate in January.  Our plan is to have that build be ASP.NET MVC V1 API and feature-complete and have zero known bugs.  We'll give people a short period to upgrade to it, give it a good tire-kicking, and report any last minute issues they find.  We'll then ship the official V1 release shortly after that (so not far off now).

Hope this helps,

Scott

I'm flying out later today on a pretty intense business trip (22,000 miles, 5 countries, 3 continents, 1 week, no sleep... :-), so my blog activity over the next week and a half will be pretty light.  To keep you busy till I return, here is the latest in my link-listing series.  Also check out my ASP.NET Tips, Tricks and Tutorials page and Silverlight Tutorials page for links to popular articles I've done myself in the past.

ASP.NET

  • Geolocation/Geotargeting Reverse IP Lookup Code: Scott Hanselman has a cool sample that demonstrates how to perform IP address lookups on users visiting your site to determine where they are located on the globe (down to the latitude and longitude).  Pretty cool stuff.

  • Tracking User Activity: Scott Mitchell has a nice article that discusses how to track end-user activity when visiting an ASP.NET web site.

  • iTunes Data Grid Skin: Matt Berseth continues his cool series showing off cool new skins you can apply to ASP.NET controls (especially the GridView and DetailsView controls).  This post shows off a pretty sweet iTunes like skin.

ASP.NET Dynamic Data

  • ASP.NET Dynamic Data Videos: Joe Stagner has 6 nice ASP.NET Dynamic Data "How Do I?" videos posted on www.asp.net that you can check out to learn about the new ASP.NET Dynamic Data feature in .NET 3.5 SP1.

  • ASP.NET Dynamic Data Routing: Rachel Appel has a nice post that talks about how to use the new ASP.NET routing features with ASP.NET Dynamic Data to enable customized URLs.

ASP.NET AJAX

ASP.NET MVC

  • How to Setup ASP.NET MVC on IIS6: Phil Haack has a great post that walks-through how to enable ASP.NET MVC on IIS6 servers (including how to enable it on a hosting server that you can't install anything on).

  • Fluent Route Testing in ASP.NET MVC: Ben Scheirman has a nice post where he blogs about new helper methods he is creating that make it easier to unit test ASP.NET MVC routes using a fluent API.

Visual Studio

WPF / Silverlight

  • XAML Power Toys - Instant Form Creation: Karl Shifflett has a great video that shows off his XAML Power Toys tool that integrates into Visual Studio and enables rapid forms creation for WPF and Silverlight.

Hope this helps,

Scott

Basic Instincts: XML Programming in Visual Basic 9.0

by Jonathan Aneja at 16:00 PM, 12/17/2007

With Visual Basic 9.0, working with XML gets much easier for developers. Here’s a look at some of the new features, including LINQ support, XML literals, embedded expressions, XML properties, and XML Schema IntelliSense.

Basic Instincts: Extension Methods

by Adrian Spotty Bowles at 17:00 PM, 09/27/2007

This column discusses one of the new features of Visual Basic 2008—Extension Methods. This powerful new feature was introduced to support LINQ. See what extension methods are, how to apply them yourself, and get some great usage tips.

Basic Instincts: Type inference in Visual Basic 2008

by Bill Horst at 17:00 PM, 09/18/2007

Visual Basic 2008 provides type inference to get the language ready to take advantage of LINQ and make your code more robust.

Basic Instincts: Lambda Expressions

by Timothy Ng at 17:00 PM, 07/16/2007

Sample the basic concepts of lambda expressions, explore their benefits, and witness how to use them to write more expressive programs.

Basic Instincts: Query Comprehensions

by Scott Wisniewski at 17:00 PM, 06/18/2007

Scott Wisniewski digs into LINQ and builds a custom query provider to create queries in real-world apps.

Basic Instincts: Server-Side Generation of Word 2007 Docs

by Ted Pattison at 17:00 PM, 10/11/2006

This month, Office Open XML, which allows ASP.NET and SharePoint developers to read, write, and generate Word, Excel, and PowerPoint documents on the server without running an Office desktop application there.

Basic Instincts: Resources and Localization in ASP.NET 2.0

by Ted Pattison at 17:00 PM, 07/05/2006

In this installment of Advanced Basics Ted Pattison discusses the localization of Web sites in ASP.NET 2.0.

Basic Instincts: Resources and localization.

by Ted Pattison at 17:00 PM, 04/05/2006

This month: everything you wanted to know about how to handle resource localization efficiently.

Basic Instincts: Introducing ASP.NET Web Part Connections

by Ted Pattison at 16:00 PM, 01/09/2006

Basic Instincts: Introducing ASP.NET Web Part Connections

Basic Instincts: Programming I/O with Streams in Visual Basic .NET

Basic Instincts: Reflection in Visual Basic .NET

by Ted Pattison at 17:00 PM, 07/11/2005

Basic Instincts: Reflection in Visual Basic .NET

Basic Instincts: Designing With Custom Attributes

by Ted Pattison at 17:00 PM, 04/11/2005

Basic Instincts: Designing With Custom Attributes

Basic Instincts: Using the ReaderWriterLock Class

by Ted Pattison at 16:00 PM, 01/10/2005

Basic Instincts: Using the ReaderWriterLock Class

Basic Instincts: Thread Synchronization

by Ted Pattison at 17:00 PM, 08/16/2004

Basic Instincts: Thread Synchronization

Basic Instincts: Creating and Managing Secondary Threads

by Ted Pattison at 17:00 PM, 05/17/2004

Basic Instincts: Creating and Managing Secondary Threads

Basic Instincts: Updating the UI from a Secondary Thread

by Ted Pattison at 17:00 PM, 04/19/2004

Basic Instincts: Updating the UI from a Secondary Thread

Basic Instincts: Asynchronous Method Execution Using Delegates

by Ted Pattison at 16:00 PM, 12/15/2003

Basic Instincts: Asynchronous Method Execution Using Delegates

Basic Instincts: Deploying Assemblies

by Ted Pattison at 17:00 PM, 09/15/2003

Basic Instincts: Deploying Assemblies

Learn what the different parts of an assembly name mean, how to create a stronly named assembly, and get other assembly security tips.

Basic Instincts: Programming Events of the Framework Class Libraries

Basic Instincts: Static Event Binding Using WithEvents

by Ted Pattison at 16:00 PM, 02/10/2003

Basic Instincts: Static Event Binding Using WithEvents

Basic Instincts: Programming with Events Using .NET

by Ted Pattison at 16:00 PM, 01/13/2003

Basic Instincts: Programming with Events Using .NET

Basic Instincts: Implementing Callbacks with a Multicast Delegate

Basic Instincts: Implementing Callback Notifications Using Delegates

Basic Instincts: Objects and Values, Part 2: Memory Management

by Ted Pattison at 17:00 PM, 09/16/2002

Basic Instincts: Objects and Values, Part 2: Memory Management

Basic Instincts: Objects and Values, Part I

by Ted Pattison at 17:00 PM, 05/13/2002

Basic Instincts: Objects and Values, Part I

Basic Instincts: Using Inheritance in the .NET World, Part 2

by Ted Pattison at 16:00 PM, 11/12/2001

Basic Instincts: Using Inheritance in the .NET World, Part 2

Basic Instincts: Using Inheritance in the .NET World

by Ted Pattison at 17:00 PM, 10/15/2001

Basic Instincts: Using Inheritance in the .NET World

Basic Instincts: Exploiting New Language Features in Visual Basic .NET, Part 2

Basic Instincts: New Features in Visual Basic .NET: Variables, Types, Arrays, and Properties

Basic Instincts: To Cache or not to Cache

by Ted Pattison at 17:00 PM, 10/16/2000

Basic Instincts: To Cache or not to Cache

Basic Instincts: Automating COM+ Administration

by Ted Pattison at 17:00 PM, 08/14/2000

Basic Instincts: Automating COM+ Administration

Basic Instincts: Porting Apps from MTS to COM+

by Ted Pattison at 17:00 PM, 04/17/2000

Basic Instincts: Porting Apps from MTS to COM+

Basic Instincts: Porting Applications from MTS to COM+

by Ted Pattison at 16:00 PM, 02/14/2000

Basic Instincts: Porting Applications from MTS to COM+

2008 scandalz.net
Another good night not to sleep in a eucalyptus tree.
CountryUS
IP Address38.103.63.59
User AgentCCBot/1.0 (+http://www.commoncrawl.org/bot.html)