scandalz.net
 
 
 
BETA (Google AJAX Search)

Template

This is the template.

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

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 

 

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/

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

IIS 7.0: Build Web Server Solutions with End-To-End Extensibility

by Mike Volodarsky at 16:00 PM, 01/22/2008

Mike Volodarsky demonstrates the IIS 7.0 extensibility model by extending the Response Modification into a configurable Web server module and a custom management page for IIS Manager.

Cutting Edge: Modal Dialog Boxes with AJAX

by Dino Esposito at 16:00 PM, 01/22/2008

This month Dino Esposito shows you how to get Windows-style modal dialog boxes for your Web applications thanks to the Ajax Control Toolkit and some clever coding.

Service Station: Web Service Software Factory Modeling Edition

by Gerardo de Geest and Gerben van Loon at 16:00 PM, 01/22/2008

Web Service Software Factory: Modeling Edition is a collection of resources for modeling and building Web services for Windows Communication Foundation and ASMX.

Powerful Text Editing, Web Testing in .NET, Extended Unit Testing, and More

Cutting Edge: Customize Controls with AJAX Extenders, Part 2

by Dino Esposito at 16:00 PM, 12/17/2007

This month Dino looks at AJAX control extenders again, adding more advanced features including masked editing and autocompletion.

World Ready: Around the World with ASP.NET AJAX Applications

by Guy Smith-Ferrier at 16:00 PM, 12/10/2007

The .NET Framework has excellent internationalization support, but JavaScript does not. If you’re using ASP.NET AJAX, learn what you need to do to adapt.

Introducing Web-centric features of Windows Communication Foundation in the .NET Framework 3.5, including the HTTP programming model and the new syndication API.

Cutting Edge: Customize Controls with AJAX Extenders

by Dino Esposito at 16:00 PM, 12/10/2007

AJAX Extenders extend the behavior and features of ordinary Web controls so you can reduce postbacks and control input even better than with AJAX alone.

Wicked Code: Drag and Drop with ASP.NET AJAX

by Jeff Prosise at 16:00 PM, 12/10/2007

Jeff Prosise shows how you can implement drag-and-drop functionality in your Web app with ASP.NET AJAX.

Cutting Edge: Inside the Microsoft AJAX Library

by Dino Esposito at 17:00 PM, 10/23/2007

Dino Esposito introduces the Microsoft AJAX Library and the JavaScript library for ASP.NET AJAX 1.0.

Cutting Edge: Managing the User Experience in AJAX

by Dino Esposito at 17:00 PM, 09/27/2007

This month Dino takes a look at limitations and UI issues in Partial Rendering AJAX pages and techniques for managing the UI.

Cutting Edge: AJAX application architecture, Part 2

by Dino Esposito at 17:00 PM, 09/18/2007

The second of this two-part series delves into the script services programming model, which is useful if you’re looking for a full paradigm shift in building AJAX applications.

ASP.NET: ScriptManager Enables AJAX In Your Web Apps

by Ben Rush at 17:00 PM, 07/16/2007

Learn how to use the ScriptManager control, which provides much of the magic behind ASP.NET AJAX.

IIS 7.0: Extend Your WCF Services Beyond HTTP With WAS

by Dominick Baier, Christian Weyer, and Steve Maine at 17:00 PM, 07/16/2007

Learn about a new IIS feature called the Windows Process Activation Service (WAS) that makes it possible to host Web services beyond HTTP.

Cutting Edge: AJAX Application Architecture, Part 1

by Dino Esposito at 17:00 PM, 07/16/2007

In the first of a two-part column, Dino explains AJAX from an architectural standpoint to help developers, architects, designers, and administrators better understand the issues that affect their sites.

Cutting Edge: Canceling Server Tasks with ASP.NET AJAX

by Dino Esposito at 17:00 PM, 06/18/2007

This month Dino explains how to remotely cancel tasks running on the server using ASP.NET AJAX.

Extreme ASP.NET: Web Client Software Factory

by Fritz Onion at 17:00 PM, 06/18/2007

The Web Service Software Factory is designed to provide guidance and enhanced tools for building Web services using ASMX or WCF.

Cutting Edge: Context-Sensitive Feedback with AJAX

by Dino Esposito at 17:00 PM, 05/21/2007

Beyond progress bars: talking to server-side apps with ASP.NET AJAX.

Network Programming with .NET 2.0 - Part II

by jmanners at 15:31 PM, 05/01/2007

The long-waited second part of my article on network progamming has just been published.  Check it out:

Network Programming with .NET 2.0 - Part II (Spanish)

 

SILVERLIGHT: Get Started Building A Deeper Experience Across The Web

by Laurence Moroney at 17:00 PM, 04/17/2007

Build rich, compelling, cross-platform, interactive applications with Microsoft Silverlight.

JavaScript really does have object-oriented capabilities after all. Ray Djajadinata explains.

Migration: Convert A Java Web Application To ASP.NET Using JLCA

by Brian Jimerson at 17:00 PM, 04/10/2007

Learn how to convert a Java Web application to an ASP.NET C# application using the Microsoft Java Language Conversion Assistant.

Microsoft Office Groove 2007 helps solve data access, concurrency, and other problems inherent in remote access collaboration scenarios.

ASP.NET 2.0: Enforce Web Standards For Better Accessibility

by Ben Waldron at 17:00 PM, 03/12/2007

Web standards are about much more than closing HTML tags. They are a critical factor in how well software components can be used in future contexts.

Extreme ASP.NET: Web Deployment Projects

by Fritz Onion at 17:00 PM, 03/12/2007

ASP.NET 2.0 supports several methods for deploying Web sites to production. Web Deployment Projects add yet another worthwhile approach. Fritz Onion explains.

IIS 7.0: Explore The Web Server For Windows Vista And Beyond

by Mike Volodarsky at 16:00 PM, 01/14/2007

IIS 7.0 takes the speed, reliability, and security of IIS 6.0 and turns it into a highly extensible and manageable Web server that will run Web apps of the future.

ASP.NET 2.0: Manage Web Users With Custom Profile Providers

by Jason N. Gaylord at 16:00 PM, 01/14/2007

In ASP.NET 2.0 profile providers allow you to manage users more efficiently. Learn how here.

Service Station: BizTalk Server 2006 Web Services

by Aaron Skonnard at 16:00 PM, 01/14/2007

This month Aaron Skonnard introduces the exciting world of BizTalk Server 2006 and its support for today's Web services technologies.

{End Bracket}: Developing the Virtual Earth 3D Control

by Duncan Lawler at 16:00 PM, 01/14/2007

Everything you wanted to know about using the Virtual Earth 3D control.

Toolbox: Rich Web App UIs, Tools for Regular Expressions, and More

by Scott Mitchell at 16:00 PM, 12/20/2006

In this issue, create rich Web app UIs, explore tools for regular expressions, and create screen mockups.

Test Run: AJAX Test Automation

by Dr. James McCaffrey at 16:00 PM, 12/20/2006

This month James McCaffrey presents a technique that allows you to write lightweight test automation to verify the functionality of AJAX Web applications.

Cutting Edge: Perspectives on ASP.NET AJAX

by Dino Esposito at 16:00 PM, 12/20/2006

AJAX allows you to build rich browser applications using powerful combinations of existing client-side Web technologies. This month Dino delves into AJAX

Microsoft AJAX Library and the ASP.NET 2.0 AJAX Extensions provide a number of compelling features ranging from client-side data binding, to DHTML animations and behaviors. Learn all about them here.

VSS-enabled source code header

by jmanners at 22:14 PM, 11/10/2006

Yes, I know we all have our feelings for VSS, but I've been using this little trick (for the lack of a better word) for several years now, and I thought it's about time for me to post it here in case is beneficial to anybody else.  At the very first line on many of my programs you will find a region similar to the following:

#region Version Header
/// <remarks>
///     $Workfile: MyLogger.cs $
///   Description: This class implements a logging mechanism by wrapping the ABC Library.
///        Author: José Luis Manners     Docs: José Luis Manners
///       Created: 07/30/2004 13:23:35pm
///      $Modtime: 08/21/2004 09:35:23am $
///     $Revision: 3 $
///     Copyright: © 2004 Company Name goes here
/// </remarks>
#endregion

This is basically a header I use to document every .cs file.  There's not worst feeling in the world than having to modify somebody else's code (or perhaps and old code of yours) and not even knowing what it's suppose to do or how its purpose has changed overtime.  What's interesting about this header is that it takes advantage of the keyword expansion capabilities of VSS, so things like file name, modification date, version, etc., are automatically updated in the code by VSS every time you do a check-in.  The keywords are those enclosed in '$', btw.

To make your life easier and avoid copy and pasting each time you create a new cs file, you can create a wizard template that has this header embedded in it, and when you create a new class the header will be automatically included with the code generated by VS.NET (you can find lots of information online on how to do modify VS.NET templates).  In my case, everytime I create a new C# file I run a macro I wrote that prompts me for the description and takes care of filling in the non-VSS sections, including putting the system date in the "Created:" session, and generates the entire header.

There is a VSS keyword which I'm not showing and that is "$History: $".  With this keyword you can have VSS keep a log of all the changes directly in your code, so information like version, remarks, name of person that checked-in that version, dates, etc., are stamped in your code.  This is basically the information you can see from within VSS when you select "Show History" on a file and click on "History Details".  Althought having all this historical information directly in the source code is a little overwhelming to some people (none the last redundant), it could also be very beneficial to others - you take your pick.

HINT:  You can put the history log on a separate region in your code, that way it's "out of your way".

For more information on VSS keyword expansion features and the entire list of available keywords see the following link:

Visual SourceSafe Keyword Expansion Support

 

Data Points: RSS Feeds on a Smartphone

by John Papa at 17:00 PM, 10/17/2006

John Papa builds a Windows Mobile 5.0 application that reads RSS feeds and loads them into an ADO.NET DataSet.

Service Station: Web Service Software Factory

by Aaron Skonnard at 17:00 PM, 10/17/2006

Web Service Software Factory is designed to help you build Web service solutions that follow known architecture and design patterns, as Aaron Skonnard explains here.

Code for Jacksonville talk

by jmanners at 23:16 PM, 08/27/2006

Thank you everyone for coming to my talk this past weekend at the Jacksonville Code Camp held in beautiful (and always under construction) Jacksonville, Florida.  For those of you who asked, you can get the code I used during my demos from the following link:

Code for Jacksonville Code Camp 2006

Also, you can get more information regarding the temperature monitor and the serial/ethernet device server I used on my demos from the manufacturers links below:

Due to the distributed nature of a business process it makes sense for a workflow to be deployed as a distributed application. See how Windows Workflow and Web Services hold the key.

Inside MSDN: Consuming MSDN Web Services

by Craig Andera at 17:00 PM, 08/08/2006

Get the inside track on how the MSDN team uses Web Services to power MSDN2.

Cutting Edge: Simplify task progress with ASP.NET "Atlas"

by Dino Esposito at 17:00 PM, 08/08/2006

Dino Esposito rewrites his task progress bar with the help of ASP.NET "Atlas."

Wicked Code: Running ASMX Web Services on STA Threads

by Jeff Prosise at 17:00 PM, 08/08/2006

Jeff Prosise describes performance problems in an ASMX Web service that relied on legacy COM and Visual Basic 6.0 to perform key processing tasks and the approach he took to find a fix.

In this article, Chandu Thota highlights some of the most salient features of the Virtual Earth APIs and shows you how to build your own powerful mapping and local search applications using them.

Atlas At Last: ASP.NET Atlas Powers The AJAX-Style Sites You've Been Waiting For

Web App Follies: Keep Sites Running Smoothly By Avoiding These 10 Common ASP.NET Pitfalls

Editor's Note: Get Ready for AJAX

by author at 17:00 PM, 06/07/2006

Editor's Note: Get Ready for AJAX

Inside MSDN: Building the MSDN aggregation system

by John Mollman at 17:00 PM, 06/07/2006

Inside MSDN: Building the MSDN aggregation system

Extreme ASP.NET: Asynchronous Web Parts

by Fritz Onion at 17:00 PM, 06/07/2006

Extreme ASP.NET: Asynchronous Web Parts

This article discusses a new load test tool in Visual Studio 2005 Team System for performance and stress testing your Web sites, Web services, and other server components. Combined with its handy reporting capabilities, the load test tool provides some powerful options for sharing and managing test results.

C++ at Work: Web version checking, adding sound to an app.

by Paul DiLascia at 17:00 PM, 04/05/2006

This month: CWebVersion revisited using HTTP instead of FTP, and adding sounds to an MFC-based app.

C# Frequently Asked Questions

by jmanners at 15:47 PM, 03/30/2006

Continuing with the posts on good online resources, you should check this one out once in a while or better yet, subscribe to the RSS Feed:

C# Frequently Asked Questions

How to enumerate the forms in a project

by jmanners at 13:40 PM, 03/13/2006

Someone posted a message in one of the many newsgroups I frequently visit.  He needed to find out at runtime how many Windows forms exist in a project.  Here's the message and my solution to his problem in case anybody else finds it useful:

"Saludos

Estoy haciendo un proyecto WinForm y requiero saber cómo puedo ver las
formas que están dentro del proyecto

Claro , con el explorador en modo diseño, solo que requiero verlas en en
tiempo de corrida. No se si conoces en Access el objeto forms collection que
te muestra las características de las formas de la currentdb, de manera que
yo pudiera recorrer con una instruccion for each... todas y cada una de las
formas y abrir una en particular. En Visual .net yo puedo instanciar una
forma, pero lo hago sabiendo su nombre : no puedo por ejemplo decir
for each frm in forms
  if frm.name='XXXX'
    frm.show
   exit for
endif
next
ya que no existe el objeto forms que me muestre las formas del proyecto.

gracias
"

We can easily obtain this information at runtime using Reflection.  All we have to do is call the GetExecutingAssembly method to obtain an Assembly object that points to the assembly we're executing (our current project), we then call GetTypes on that assembly object to get a list of all the types defined inside of it.  The rest is just looping through the list and check which type(s) match what we're looking for, in this case we're looking for Windows forms:

    Type[] tipos = System.Reflection.Assembly.GetExecutingAssembly().GetTypes(); 

    foreach(Type tipo in tipos)

    {

        if (tipo.BaseType.FullName == "System.Windows.Forms.Form")

        {

            object objeto = Activator.CreateInstance(tipo, true);

            System.Windows.Forms.Form formulario = objeto as System.Windows.Forms.Form;

            formulario.Show();  // do something with the instantiated form

        } 

    }

If anybody has a more elegant, clever, faster, easier, etc., etc., way to do it, I'm all ears.

Toolbox: Analyze HTTP Traffic, Synchronize Databases, and More

by Scott Mitchell at 16:00 PM, 03/08/2006

Toolbox: Analyze HTTP Traffic, Synchronize Databases, and More

I'm a MCAD.NET

by jmanners at 11:02 AM, 02/18/2006

Today I passed exam 70-320 Developing XML Web Services and Server Components with Microsoft Visual C# .NET and the Microsoft .NET Framework , which was the last exam I needed to pass in order to complete my MCAD.NET certification.  It's time to celebrate!!

Populating a ListBox with month names

by jmanners at 15:57 PM, 02/02/2006

Somebody posted a message in the C# newsgroup asking for a way to populate a ListBox with the name of the months in Spanish.  He basically had created an enum and wanted to fill up the ListBox from that enum.  The enum looks like this:

    public enum Meses:int
    {
        Enero=1,
        Febrero = 2,
        Marzo = 3,
        Abril = 4,
        Mayo = 5,
        Junio = 6,
        Julio = 7,
        Agosto = 8,
        Septiembre = 9,
        Octubre = 10,
        Noviembre = 11,
        Diciembre = 12
    }

At first, one of the most simple ways that comes to mind is to do something similar to this:

            ListBox listBox1 = new ListBox();
            listBox1.Items.Add(Meses.Enero);
            listBox1.Items.Add(Meses.Febrero);
            listBox1.Items.Add(Meses.Marzo);
            listBox1.Items.Add(Meses.Abril);
            listBox1.Items.Add(Meses.Mayo);
            listBox1.Items.Add(Meses.Junio);
            listBox1.Items.Add(Meses.Julio);
            listBox1.Items.Add(Meses.Agosto);
            listBox1.Items.Add(Meses.Septiembre);
            listBox1.Items.Add(Meses.Octubre);
            listBox1.Items.Add(Meses.Noviembre);
            listBox1.Items.Add(Meses.Diciembre);

This solution works fine, it does what's needed.  But what happens if you want to have a localized version of your application in another language?  It would look strange to have a ListBox with a label that says "Please select a month: " and the months inside the ListBox shown in Spanish, don't you think?.  Besides, the values are kind of hard-coded  in a sense, and personally, I've never been a fan of hard-coding anything.

Here comes CultureInfo to the rescue

Like with many other things in software development, there is always more than one way to produce the same results, and this is no exception.  Believe or not, the 13 lines of code from the previous example could be easily reduced to only 3 (yes, you heard me right!!).  All you really need to do is use a CultureInfo object and its DateTimeFormat property so you can get an array of strings with the name of the months already translated into the language of the culture you want.  We then just add the array to the Items collection of the ListBox using the AddRange method:

// Get the CultureInfo from the Dominican Republic
// we're using it to get the months in Spanish
CultureInfo culture = new CultureInfo("es-DO");
 // Add the range of months to ListBox
ListBox listBox1 = new ListBox();
listBox1.Items.AddRange(culture.DateTimeFormat.MonthNames);

Give it a shot and let me know what you think.

ASP.NET 2.0 aims to reduce the amount of code required to accomplish common Web programming tasks by 70 percent or more. New services, controls, and features make it almost as dramatic an improvement to ASP.NET 1.x as that was to ASP Classic. Here Jeff Prosise explores the new features.

so you wanna program in C#?

by jmanners at 14:25 PM, 01/13/2006

If you want to develop (or continue "sharpening") your C# programming skills.  I'd recommend you frequently check the Centro de Desarrollo Microsoft Visual C# (for Spanish speakers) or the Visual C# Developer Center (for English speakers).  These two great C# resources contain courses, articles, technical presentations, and some other goodies which you can access directly from the respective site.

Or better yet, if you speak both languages... well you get the idea.

This article describes the WSE policy framework, which allows you to describe constraints and requirements a Web service must enforce. Discussions include security scenarios in WSE 3.0 and extending the framework with custom constraints and requirements.

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

Pure C++: Live Source Browsing in Visual C++

by Boris Jabes and Ameya Limaye at 16:00 PM, 01/09/2006

Pure C++: Live Source Browsing in Visual C++

How to disable the [X] button in a Windows form

by jmanners at 14:54 PM, 01/03/2006

Recently I had a need to create a Form with a disabled close button.  Believe or not, this simple task cannot done be achieved by simply configuring a property at design time, because no such design-time property exists.  One alternative is to set the ControlBox property to "false", but in reality this removes the three buttons (minimize, maximize, and close) altogether.

After a little "googling" I found some examples but they were all using P/Invoke and/or were written in VB.  But then I remembered that during my good old days of Win32/C++/MFC programming I used to change the visual style of a window class by setting up values from the constants in the include file winuser.h.  In that file there was a constant named CS_NOCLOSE which was used to disable the close button in the window.  That's cool, but... how can I use that stuff now?

Well, reading the beloved MSDN documentation (I really mean that) it turns out that the Form class has a property named CreateParams which allows you to set parameters that define the appearance of the form before it gets created.  So the only thing that needs to be done is to override this property in my Form and add the value for CS_NOCLOSE that we want.  Something similar to this:

        protected override CreateParams CreateParams

        {

            get

            {

                const int CS_NOCLOSE = 0x200;

                CreateParams cp = new CreateParams();

                cp = base.CreateParams;

                cp.ClassStyle = cp.ClassStyle | CS_NOCLOSE;

                return cp;

            }

        }

voilá, it works!!  BTW, if you like to know where the include file is, it should be under “C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include”, or something close to that depending on your installation of the Framework.  Here's a snapshot of how it looks like if your curious:

 2425 /*

 2426  * Class styles

 2427  */

 2428 #define CS_VREDRAW          0x0001

 2429 #define CS_HREDRAW          0x0002

 2430 #define CS_DBLCLKS          0x0008

 2431 #define CS_OWNDC            0x0020

 2432 #define CS_CLASSDC          0x0040

 2433 #define CS_PARENTDC        0x0080

 2434 #define CS_NOCLOSE          0x0200

 2435 #define CS_SAVEBITS        0x0800

 2436 #define CS_BYTEALIGNCLIENT  0x1000

 2437 #define CS_BYTEALIGNWINDOW  0x2000

 2438 #define CS_GLOBALCLASS      0x4000

 2439 

 2440 #define CS_IME              0x00010000

 2441 #if(_WIN32_WINNT >= 0x0501)

 2442 #define CS_DROPSHADOW       0x00020000

 2443 #endif /* _WIN32_WINNT >= 0x0501 */

How to use log4net

by jmanners at 20:31 PM, 10/26/2005

Like with the Datagrid Jerárquico (Hierarchical Datagrid) sample application, for long time I've been receiving emails from people asking me to send them an example on how to use log4net.  So, I've figured is about time to put something together and keep it centralized so everybody can get it instead keep sending it via email.  You can get this little app from the "Attachments" link.

Ensuring the security of a Web application is critical and requires careful planning throughout the design, development, deployment, and operation phases. It is not something that can be slapped onto an existing application. In this article, Mike Volodarsky outlines best practices that allow you to take advantage of the security features of ASP.NET 2.0 and IIS 6.0 to build and deploy more secure Web applications.

In this article, Niels Flensted-Jensen demonstrates how you can combine new and existing Microsoft technologies with minimal new code to provide flexible authorization for individual Web service methods. Windows 2003 Authorization Manager, Web Service Enhancements 3.0, and Enterprise Library all play a part.

Web Q&A: ASP.NET Session State, Validation, DataGrids, and More

by Edited by Nancy Michell at 17:00 PM, 10/10/2005

Web Q&A: ASP.NET Session State, Validation, DataGrids, and More

<example>, <code> and NDoc

by jmanners at 15:01 PM, 09/26/2005

Quite frequently I see posts like this in the Microsoft Newsgroups:

"I am documenting my code with the XML tags included in .NET for this, but my comments inside these tags do not show"

Well, the first thing you need to do is to configure the project in VS.NET so that it generates XML documentation.  This can be done in the property window under the "Build" tag, put the name of the XML file you want to generate under "XML Dcomentation File".  Now complie your project and a file with the XML comments will be created.

Now take this file and process it with NDoc.  This tool allows you to generate MSDN-like documentation of your code.  This type of documentation will show the code included within the <example> and <code> tags.

 

Test Run: Low-Level Web App UI Test Automation

by James McCaffrey at 17:00 PM, 09/12/2005

Test Run: Low-Level Web App UI Test Automation

ASP.NET provides a number of ways to maintain user state, the most powerful of which is session state. This article takes an in-depth look at designing and deploying high-performance, scalable, secure session solutions, and presents best practices for both existing and new ASP.NET session state features straight from the ASP.NET feature team.

ASP.NET 2.0: Personalize Your Portal with User Controls and Custom Web Parts

by Ted Pattison and Fritz Onion at 17:00 PM, 08/08/2005

ASP.NET 2.0 introduces a Web Part control that is designed to deal with the serialization, storage, and retrieval of customization and personalization data behind the scenes. In this article, the authors explain how you can put the WebPart control to work in your ASP.NET 2.0 applications.

Web Q&A: Smart Navigation, ASP.NET Project Structure, and More

by Edited by Nancy Michell at 17:00 PM, 08/08/2005

Web Q&A: Smart Navigation, ASP.NET Project Structure, and More

Web Q&A: Web Page Layout, Quirks Mode, and More

by Edited by Nancy Michell at 17:00 PM, 06/13/2005

Web Q&A: Web Page Layout, Quirks Mode, and More

Cutting Edge: DHTML-Enabled ASP.NET Controls

by Dino Esposito at 17:00 PM, 06/13/2005

Cutting Edge: DHTML-Enabled ASP.NET Controls

New Recommendations for Using Strings in .NET 2.0

by jmanners at 12:59 PM, 06/02/2005

Dave Fetterman of the Microsoft's .NET Base Class Library (BCL) Team just published this paper on using some of the new culture-agnostic methods of the String class in favor of using CultureInfo.InvariantCulture when writing localized applications.

Say What? Make Sense of Your Web Feedback using SQL Server 2005

by Peter Pyungchul Kim at 17:00 PM, 05/09/2005

By now, you're certainly collecting a variety of data from your Web site. But once you collect it, what do you do with it. For it to be meaningful, this data must be categorized and analyzed. The SQL Server 2005 data mining functionalities can help you get the most out of those reams of data you collect, as Peter Pyungchul Kim explains.

Web Q&A: Locking Pop-Up Blocker, Mixed Authentication, and More

by Edited by Nancy Michell at 17:00 PM, 05/09/2005

Web Q&A: Locking Pop-Up Blocker, Mixed Authentication, and More

C++ at Work: Counting MDI Children, Browsing for Folders

by Paul DiLascia at 17:00 PM, 05/09/2005

C++ at Work: Counting MDI Children, Browsing for Folders

Web Q&A: ASP.NET Performance, Notification, Keeping Sort Order, and More

by Edited by Nancy Michell at 17:00 PM, 04/11/2005

Web Q&A: ASP.NET Performance, Notification, Keeping Sort Order, and More

Web Q&A: Get Authentication Type, Get Screen Resolution, and More

by Edited by Nancy Michell at 16:00 PM, 03/14/2005

Web Q&A: Get Authentication Type, Get Screen Resolution, and More

Test Run: Lightweight UI Test Automation for ASP.NET Web Apps

by James McCaffrey at 16:00 PM, 03/14/2005

Test Run: Lightweight UI Test Automation for ASP.NET Web Apps

Service Station: Developing .NET Web Services with Beta 2

by Aaron Skonnard at 16:00 PM, 03/14/2005

Service Station: Developing .NET Web Services with Beta 2

The very tools that have helped drive the growing adoption of Web services, and the enabling abstractions that they provide, can often prevent developers from peeking behind the curtains at the XML standards that make up the Web services stack. This article will offer a solution that enables type sharing between proxies created for complementary Web services, while at the same time providing an opportunity to examine the Web Services Description Language (WSDL) and its interaction with the Web services tools you know and love.

In this article the author focuses on one critically important Web services specification that has been largely overlooked: the Business Process Execution Language for Web Services (BPEL4WS, or BPEL). He describes why BPEL is important and what it offers you if you are implementing Web services today or planning to in the future. Concrete examples using BizTalk Server 2004 are presented in the article.

If you want to schedule ASP.NET tasks, one solution is to use a Web service to provide an interface to your ASP.NET application and build a Windows service that calls to it at scheduled intervals. Thus the ASP.NET application doesn't have to own the scheduling logic. Here the author shows how to schedule your ASP.NET tasks using a Windows service to initiate the Web service call because Windows services can start themselves when Windows boots up.

Web Services use XML to communicate with each other. But sometimes the XML your service emits is not the same XML that another service is expecting. If you want to avoid the problems that this kind of situation can cause, you need to get good control over your XML serialization. Here author Chris Dix shows you exactly how to tackle this problem.

Web Q&A: Data Integrity Over HTTP, IIS Credentials, DataGrids, and More

by Edited by Nancy Michell at 16:00 PM, 02/14/2005

Web Q&A: Data Integrity Over HTTP, IIS Credentials, DataGrids, and More

Test Run: Automate Your ASP.NET Web Services Testing

by James McCaffrey at 16:00 PM, 02/14/2005

Test Run: Automate Your ASP.NET Web Services Testing

Inside MSDN: Using InfoPath as a Reporting Solution

by Larry W. Jordan Jr. at 16:00 PM, 02/14/2005

Inside MSDN: Using InfoPath as a Reporting Solution

C++ at Work: Making Static Links Keyboard-Capable, Launching URLs from Your App

C# 2.0 at FladotNet

by jmanners at 11:05 AM, 01/31/2005


Last week we had David McNamee from developerLabs, Inc. talking about some of the new features that will ship with C# 2.0. Although this is a well known subject among .NET ranks, what made his an interesting presentation was the practical and straight-forward way on which David treated topics like: generics, anonymous methods, partial classes, etc., and if you add to that his enthusiasm for .NET, then you have a great presentation in my opinion.

Another thing I liked was the way code was presented. Unlike other speakers that already have some pre-written code and all they do is add a few lines here and there, David wrote all the code from scratch. I think this technique gives the audience a better sense of knowing where everything is or coming from, while makes them more participant as the code progresses.

Good job David and hope to see you at CodeCamp this coming weekend !!

Excel 2003 lets you dynamically integrate the data provided by different Web services. It also lets you take advantage of the latest capabilities in Office 2003 to customize list views, graphs, and charts, and to catalog bulk items online or offline. Find out how you can makle the most of the data returned from your Web services with the Office 2003 Web Services Toolkit API.

Web Q&A: ActiveX Privileges, Making Icon Files, Sticky Sessions, and More

by Edited by Nancy Michell at 16:00 PM, 01/10/2005

Web Q&A: ActiveX Privileges, Making Icon Files, Sticky Sessions, and More

Inside MSDN: Designing URLs for MSDN2

by Tim Ewald at 16:00 PM, 01/10/2005

Inside MSDN: Designing URLs for MSDN2

Hierarchical Datagrid

by jmanners at 15:56 PM, 01/04/2005



I've received a few emails from people inquiring about the sample code that demostrates how to create a hierarchical datagrid. You can download the code from the "Attachments" link below. Let me know if there are any questions and/or suggestions.

Writing a Web application with ASP.NET is unbelievably easy. So many developers don't take the time to structure their applications for great performance. In this article, the author presents 10 tips for writing high-performance Web apps. The discussion is not limited to ASP.NET applications because they are just one subset of Web applications.

Web Q&A: Caching and Expiration, Connection Pools, and More

by Edited by Nancy Michell at 16:00 PM, 12/13/2004

Web Q&A: Caching and Expiration, Connection Pools, and More

The ASP Column: Determining Browser Capabilities in ASP.NET

by George Shepherd at 16:00 PM, 12/13/2004

The ASP Column: Determining Browser Capabilities in ASP.NET

Llamando funciones del Win32 API que usan LPTSTR

by jmanners at 15:20 PM, 11/29/2004

Cuando en C# necesitas llamar funciones de Win32 API que reciben cadenas de caracteres, debes ponerle cuidado al tipo de acceso que la función receptora le da al argumento como también al tipo de dato de .NET que le vas a enviar a dicha función.

Las funciones que usan cadenas de caracteres como argumentos de entra (in) pueden ser llamadas desde .NET con simplemente pasarle un objeto System.String. La traducción de System.String a LPTSTR es hecha por el compilador automáticamente mediante un mecanismo que se llama "marshaling". De esta manera la función puede acceder el argumento con el tipo de dato correcto. Pero a pesar de que el compilador hace la traducción, hay un factor adicional que hay que considerar cuando el argumento es utilizado como argumento de salida (out).

Cuando un argumento es de salida quiere decir que el argumento va a ser modificado internamente por la función receptora. Recuerda que los objetos System.String son inmutables, o sea, no se pueden cambiar y si le cambias el valor, un nuevo objeto será creado. Por lo tanto si envías el argumento como System.String cuando la función lo modifique y lo recibas nuevamente ya no va a ser el mismo objeto que originalmente enviaste. La manera de solucionar esto es pasarle a la función un objeto StringBuilder en lugar de System.String. El compilador hará la conversión de un objeto StringBuilder a un LPTSTR y cuando la función lo modifique y regrese todavía será el mismo objeto StringBuilder que enviaste.

Pongamos este conocimiento en práctica con algo de código. Vamos a llamar la función GetComputerName del Win32 API. Esta función tiene el siguiente prototipo:

BOOL GetComputerName(
 LPTSTR lpBuffer,
 LPDWORD lpnSize
);


Entonces en C# la declaramos con el siguiente prototipo:

[DllImport("kernel32.dll")]

public static extern int GetComputerName( StringBuilder buffer, ref uint size);

Cuando llamas GetComputerName la función te devuelve el nombre de tu computadora en el objeto buffer que le pasaste. Ahora bien, si cambias el prototipo para que reciba un String y llamas la función pasándole un objeto String, notarás que tu objeto no contiene el valor esperado.

Web Q&A: Windowed and Windowless Elements, Cookie Characters, and More

by Edited by Nancy Michell at 16:00 PM, 11/15/2004

Web Q&A: Windowed and Windowless Elements, Cookie Characters, and More

.NET Matters: Asynchronous HttpWebRequests, Interface Implementation, and More

Once you've addressed security in your code, it's time to look at the environment it runs in. Firewalls stop unauthorized traffic from getting into your network, and smart Web service-specific firewalls, like the one that comes with Internet Security and Acceleration (ISA) Server 2004, bring XML intrusion prevention to your system for that added layer of safety.

Web Q&A: ADO.NET Joins, HTML to XHTML, ASP.NET ViewState, and More

by Edited by Nancy Michell at 17:00 PM, 10/18/2004

Web Q&A: ADO.NET Joins, HTML to XHTML, ASP.NET ViewState, and More

Service Station: Improving Web Service Interoperability

by Aaron Skonnard at 17:00 PM, 10/18/2004

Service Station: Improving Web Service Interoperability

Web Q&A: Refreshing Web Pages, Spyware, Group Policy, and More

by Edited by Nancy Michell at 17:00 PM, 09/13/2004

Web Q&A: Refreshing Web Pages, Spyware, Group Policy, and More

Service Station: Securing Web Services with WSE 2.0

by Aaron Skonnard at 17:00 PM, 09/13/2004

Service Station: Securing Web Services with WSE 2.0

Web Q&A: Caching Transforms, Connection Sharing, and More

by Edited by Nancy Michell at 17:00 PM, 08/16/2004

Web Q&A: Caching Transforms, Connection Sharing, and More

Microsoft Office SharePoint Portal Server 2003, which is part of the Office System, lets you create and manage virtual servers, site collections, sites, workspaces, and users. You can also use the Windows SharePoint Services object model to design and implement user-targeted applications. In the second part of a two part series, the authors take a look at the WSS and SPS object models, Web Part Page anatomy, creating and deploying Web Parts, and Web Part security. They also discuss Web Part infrastructure and how to create custom Web Parts.

Web Q&A: Page Ready State, DataGrid Row Deletion, and More

by Edited by Nancy Michell at 17:00 PM, 07/19/2004

Web Q&A: Page Ready State, DataGrid Row Deletion, and More

Test Run: Test Automation for ASP.NET Web Apps with SSL

by James McCaffrey at 17:00 PM, 07/19/2004

Test Run: Test Automation for ASP.NET Web Apps with SSL

Advanced Basics: P2P Comm Using Web Services

by Carl Franklin at 17:00 PM, 07/19/2004

Advanced Basics: P2P Comm Using Web Services

This article presents a general-purpose client quality reporting mechanism that can be used in any .NET-based transaction system that employs HTTP/SOAP. The design uses client response time and quality recording, upload of logs as SOAP headers attached to new transaction requests, and server handoff of these headers to a low priority queue for logging and analysis. This technique gives an enterprise near real-time information on actual end-user response times. These response times reflect network delays, client application overhead and server delays. By using this technique, enterprises can avoid the need to develop custom software to mine HTTP logs.

Web Q&A: Pop-Ups, Encrypting an ADO.NET Data Stream, and More

by Edited by Nancy Michell at 17:00 PM, 06/14/2004

Web Q&A: Pop-Ups, Encrypting an ADO.NET Data Stream, and More

ASP.NET 2.0 has addressed some of the most common problems developers face today with a suite of controls, components and IDE tools. One such issuer is maintaining preferences information about individual users of a Web application in a uniform manner. This article drills down into ASP.NET 2.0 to illustrate how it helps solve these problems far easier than is possible today, and demonstrates how these features can be combined to build powerful, personalized Websites in very little time.

Web Q&A: Visual Studio 2005, HTC Memory Problems, and More

by Edited by Nancy Michell at 17:00 PM, 05/17/2004

Web Q&A: Visual Studio 2005, HTC Memory Problems, and More

Web Q&A: Request Timeouts, Byte Array Conversion, and More

by Edited by Nancy Michell at 17:00 PM, 04/19/2004

Web Q&A: Request Timeouts, Byte Array Conversion, and More

Web Q&A: JScript Leaks, Getting the XmlDataDocument, and ASPX Includes

by Edited by Nancy Michell at 16:00 PM, 03/15/2004

Web Q&A: JScript Leaks, Getting the XmlDataDocument, and ASPX Includes

The XML Files: All About Blogs and RSS

by Aaron Skonnard at 16:00 PM, 03/15/2004

The XML Files: All About Blogs and RSS

Web Q&A: Hard Drive Security, Comparing Two Versions of a DB, and More SQL

by Edited by Nancy Michell at 16:00 PM, 02/16/2004

Web Q&A: Hard Drive Security, Comparing Two Versions of a DB, and More SQL

Web Q&A: ANSI Chars in XML, E-commerce Architecture, and More

by Edited by Nancy Michell at 16:00 PM, 01/12/2004

Web Q&A: ANSI Chars in XML, E-commerce Architecture, and More

The ASP Column: Web Services: ATL Server Versus ASP.NET

by George Shepherd at 16:00 PM, 01/12/2004

The ASP Column: Web Services: ATL Server Versus ASP.NET

Web Q&A: DTS Follow-up, Web Services, Access Over the Network, and More

by Edited by Nancy Michell at 16:00 PM, 12/15/2003

Web Q&A: DTS Follow-up, Web Services, Access Over the Network, and More

When creating a distributed system you frequently need to provide for communication between two entities that are not in sync. Microsoft Message Queue Server (MSMQ) provides the kind of store-and-forward messaging in a pre-built infrastructure that can help you address these kinds of messaging needs. In the past, MSMQ was accessed using a COM wrapper. Now there's a .NET wrapper that lets you accomplish your messaging goals easily from your Framework-based code. To illustrate the use of the wrapper, the author builds a messaging application, sends MSMQ messages over the Web, and discusses messaging security.

Web Q&A: Virtual Directories, Releasing DB Connections, and More

by Edited by Nancy Michell at 16:00 PM, 11/17/2003

Web Q&A: Virtual Directories, Releasing DB Connections, and More

The XML Files: A Survey of Publicly Available Web Services at Microsoft

Web Q&A: Secure Passwords, Nested XML, and More

by Edited by Nancy Michell at 17:00 PM, 10/13/2003

Web Q&A: Secure Passwords, Nested XML, and More

The ASP.NET advanced templated controls, such as the DataList and DataGrid, are perfect for many data representation situations. However, when you need the flexibility to render a variety of layouts, the Repeater control is what you need. In this article the author builds a full-featured blog application to illustrate the use of the Repeater and DataList controls that render nested data in a master-detail relationship. He then discusses how to override the default implementations of these controls by adding some client-side JavaScript code that makes the blog more responsive and enhances its usability.

Web Q&A: Schema From a DataSet, Exporting SQL Data to Excel, and More

by Edited by Nancy Michell at 17:00 PM, 09/15/2003

Web Q&A: Schema From a DataSet, Exporting SQL Data to Excel, and More

Web Q&A: InfoPath Back End, WSH Script Signing, and More

by Edited by Nancy Michell at 17:00 PM, 08/11/2003

Web Q&A: InfoPath Back End, WSH Script Signing, and More

The XML Files: Introducing the Web Services Enhancements 2.0 Messaging API

The ASP Column: The Internet Explorer Toolbar Control

by George Shepherd at 17:00 PM, 08/11/2003

The ASP Column: The Internet Explorer Toolbar Control

If you're building an ASP.NET Web site you could probably use a good, solid code foundation to start with and build upon. Wouldn't it be nice to start with a complete site, make a few tweaks and customizations, and go live? The ASP.NET Starter Kits are packaged solutions that let you do just that. The five kits-Community, Reports, Commerce, Portal, and Time Tracker-supply full, reusable code that can be easily customized. In addition, there are a number of ISPs that support automatic deployment of ASP.NET Starter Kit Web sites, leaving you with little left to do when you have to get there fast. Here, the author introduces the ASP.NET Starter Kits and builds a community Web site with lots of advanced features such as ratings, user polls, upload quotas, change notifications, and themes.

Web Services: Extend the ASP.NET WebMethod Framework with Business Rules Validation

by Aaron Skonnard and Dan Sullivan at 17:00 PM, 07/14/2003

In an earlier article the authors showed how to build a custom WebMethods extension that provides XML Schema validation, a function that is lacking in ASP.NET. In the process they established a foundation for enforcing business rules during the deserialization of XML data. The technique, which is described in this article, uses declarative XPath assertions to test business rule compliance. In building this business rules validation engine, the authors integrate the validation descriptions into the WSDL file that is automatically generated by the WebMethod infrastructure. Finally, they demonstrate how to extend wsdl.exe, the tool that generates WebMethod proxy/server code from WSDL files, to make use of their extensions.

Web Q&A: Who Called the Script?, Concatenating Binary Files, and More

by Edited by Nancy Michell at 17:00 PM, 07/14/2003

This month find out which part of an HTML document has called a script, how to concatenate binary files, find a node, reference one script from another, build a GUI database front end in Access, and compare XML files.

C++ Q&A: Finding a Win32 Handle, HTML in CHtmlCtrl

by Paul DiLascia at 17:00 PM, 07/14/2003

This month Paul DiLascia discusses how to find windows with GetLastChild and outputting HTML with a C++ procedure equivalent to document.write.

Resource File: Creating Privacy-aware Web Sites

by author at 17:00 PM, 07/14/2003

Resource File: Creating Privacy-aware Web Sites

Web Services: Extend the ASP.NET WebMethod Framework by Adding XML Schema Validation

by Aaron Skonnard and Dan Sullivan at 17:00 PM, 06/16/2003

WebMethods make the development of XML Web Services easier by encapsulating a good deal of functionality, but there is still a lot of underlying XML processing that you have to be responsible for. For example, WebMethods do not validate messages against the implied schema. Because they are not validated, the response that's returned can result in unintended consequences. To address this, the authors extend the WebMethod framework by adding XML Schema validation through a custom SoapExtension class.

Web Q&A: Accessible Images, Image Format Converter, and More

by Edited by Nancy Michell at 17:00 PM, 06/16/2003

Web Q&A: Accessible Images, Image Format Converter, and More

Fortunately for developers, threading in ASP.NET is a lot easier than it was in ASP. In this article, the author takes a look at threading in the ASP.NET HTTP pipeline, and explains how threads are managed efficiently without the involvement of the developer. The article considers how the common language runtime threadpool is used by ASP.NET to service requests, looks at the pooling mechanisms used for handlers, modules, and applications, and covers both IIS 5.0 and IIS 6.0 and how they differ in their approach to request processing and thread allocation. Finally, how and when to use asynchronous handlers is discussed for developers who still need to use threads in their own applications.

Editor's Note: RSS is Here!

by author at 17:00 PM, 05/12/2003

Editor's Note: RSS is Here!

Web Q&A: Font Sizing, Internationalization in JScript, and More

by Edited by Nancy Michell at 17:00 PM, 05/12/2003

Web Q&A: Font Sizing, Internationalization in JScript, and More

Web Q&A: Storing SQL Data, URL Query Length, and More

by Edited by Nancy Michell at 17:00 PM, 04/14/2003

Web Q&A: Storing SQL Data, URL Query Length, and More

The XML Files: Web Services Encoding and More

by Aaron Skonnard at 17:00 PM, 04/14/2003

The XML Files: Web Services Encoding and More

House of Web Services: Mandatory Headers in ASP.NET Web Services

Without good security, Web Services will never reach their potential. WS-Security and its associated technologies, the focus of this article, represent the future of security for Web Services. Provided here is an overview of these emerging security standards that explains what they do, how they work, and how they get along together. Topics discussed include integrity and confidentiality and how these are provided by public key cryptography, WS-Security, and more. Some of the key components of WS-Security, such as the wsu namespace, are also covered.

Web Q&A: Consuming a DataSet in ASP.NET, XML and SQL, and More

by Edited by Nancy Michell at 16:00 PM, 03/10/2003

Web Q&A: Consuming a DataSet in ASP.NET, XML and SQL, and More

The XML Files: Web Services and DataSets

by Aaron Skonnard at 16:00 PM, 03/10/2003

The XML Files: Web Services and DataSets

Web Q&A: IDs as Anchors, Preventing Search, and More

by Edited by Nancy Michell at 16:00 PM, 02/10/2003

Web Q&A: IDs as Anchors, Preventing Search, and More

House of Web Services: Accessing Raw SOAP Messages in ASP.NET Web Services

In the .NET Framework, the CodeDOM object model can represent code in a variety of languages. This article examines how source code templates written with the Framework's System.CodeDom and System.CodeDom.Compiler namespaces allow developers to create reusable boilerplate source code that can be shared between projects. Components designed via templates improve productivity and shorten development time. Here C++-style classes and templates are simulated and code is generated in multiple languages through the creation of CodeDOM object graphs. Compiling object graphs and formatting output code are also explained.

LinkLabels are Windows Forms controls that enable a user to hyperlink to a URL that points to either the Web or the local directory system. While the SDK documentation discusses the control, it does not demonstrate how linking is accomplished, nor does it outline the power and flexibility the control provides. This article fills those gaps, showing how to link using the LinkLabel control. It also shows the flexibility of this control for the programmer using the .NET Framework. In addition, the author covers the large number of properties that allow you to customize your controls and accurately place them. Their built-in behaviors are also discussed, along with their use in both Visual Basic .NET and C#.

Web Q&A: Data Shredding, Updating the Status Bar, and More

by Edited by Nancy Michell at 16:00 PM, 01/13/2003

Web Q&A: Data Shredding, Updating the Status Bar, and More

The ASP Column: Using the Internet Explorer WebControls

by George Shepherd at 16:00 PM, 01/13/2003

The ASP Column: Using the Internet Explorer WebControls

Scale: Real-World Load Testing Tips to Avoid Bottlenecks When Your Web App Goes Live

by Jeff Dunmall and Keith Clarke at 16:00 PM, 12/16/2002

Load testing should be part and parcel of every Web development effort, and it should be performed early in the process. However, if you think you can load test using your development environment, you're going to have some surprises when you go live. In this article, the authors outline the process of planning your load testing effort, considering which machines to use, how many users to simulate, which tools are right for you, and how to interpret your results.

Web Q&A: Releasing Memory in JScript, Bulkload Problems, and More

by Edited by Nancy Michell at 16:00 PM, 12/16/2002

Web Q&A: Releasing Memory in JScript, Bulkload Problems, and More

Advanced Basics: Automatically Generating a Web Service

by Ken Spencer at 16:00 PM, 12/16/2002

Advanced Basics: Automatically Generating a Web Service

Throughout this issue, you'll read all about the promise of Web Services and how the .NET Framework enables Web Service development. Many people will also be building their Web Services atop C++ code and frameworks like ATL Server, particularly when performance is paramount. In this article, the authors show how fully functional Web Services are built using ATL Server and Visual Studio .NET. Beginning with unmanaged C++ classes, they add ATL attributes that make the code work over HTTP.

The Office XP Web Services Toolkit makes it possible to build applications that gather information and trigger transactions through various Web Services. The toolkit allows you to easily discover Web Services remotely. It also includes the Web Service Reference Tool, which lets you call a Web Service from inside an Office application. This article shows how toolkit-generated code can be used to access simple, as well as complex, Web Services. The author steps through the auto-generated code to explain the classes that collect parameters, the schema to format the request/response, and the actual operations of the Web Service.

Performance is an important concern for any application, but becomes critical when the app is a Web Service accessed by thousands of clients simultaneously. One hardware approach to distributing Web Services requests evenly is a Web farm consisting of multiple servers. Once on a Web farm, Web Service performance can be improved by using ADO.NET DataSet objects to cache frequently accessed data, reducing round-trips to the database. Here the author describes data caching in a Web farm environment and discusses how to avoid the cross-server synchronization problems inherent in this approach.

Web Services are all about exchanging data in the form of XML messages. If you were about to design a database schema, you probably wouldn't let your tool do it for you. You'd hand-tool it yourself to ensure maximum efficiency. In this article, the author maintains that designing a Web Service should be no different. You should know what kind of data will be returned by Web Service requests and use the structure of that data to design the most efficient message format. Here you'll learn how to make that determination and how to build your Web Service around the message structure.

Building Web Services to provide enterprise-level solutions is only the first step. You need to take care of the infrastructure aspects of your solution as well, including provisioning, billing, security, and reporting. In this article, the author uses the .NET Framework and SQL Server 2000 to design a provisioning system that will take care of all these housekeeping tasks. He discusses the general requirements of a Web Service provisioning system, walks through the implementation, and then outlines various scenarios for putting this system to work.

Editor's Note: The New Web Services Era

by author at 16:00 PM, 11/11/2002

Editor's Note: The New Web Services Era

Web Q&A: Web Services

by Edited by Nancy Michell at 16:00 PM, 11/11/2002

Web Q&A: Web Services

The XML Files: WSDL, Web Services, and More

by Aaron Skonnard at 16:00 PM, 11/11/2002

The XML Files: WSDL, Web Services, and More

Talking To…: Don Box Discusses Web Services and His New Role at Microsoft

If you've built Web sites using ASP.NET, you'll welcome the Microsoft Mobile Internet Toolkit (MMIT). MMIT extends the Visual Studio .NET IDE you already know by providing new controls for handheld devices letting you easily develop applications for wireless devices. This means you can write less code while adapting it to more devices. Not only does MMIT integrate with Visual Studio .NET, it extends ASP.NET as well. This article gives you the background you need to write, test, and deploy a site with MMIT and make all your code able to target specific devices for a custom fit.

Web Q&A: Mobile Internet Toolkit versus Smart Device Extensions, SSL Glitch Again, and More

The XML Files: WebMethod Validation, SOAP Validation, XmlSerializer, One-way Operations, and More

Visual Basic .NET comes loaded with features not available in previous versions, including a new threading model, custom class creation, and data streaming. Learn how to take advantage of these features with an application that is designed to extract information from Web pages for indexing purposes. This article also discusses basic database access, file I/O, extending classes for objects, and the use of opacity and transparency in forms.

Web Q&A: Allowing ASP in IIS 6.0, Sorting XML Elements, SSL and Navigation, and More

The XML Files: The Birth of Web Services

by Aaron Skonnard at 17:00 PM, 09/16/2002

The XML Files: The Birth of Web Services

Resource File: Web Services Security Specs and TrustBridge

ASP.NET is a flexible and extensible framework for server-side HTTP programming. While most people think of ASP.NET in terms of pages served, there is a lower-level infrastructure sitting beneath this page model. The underlying plumbing is based on a pipeline of app, module, and handler objects. Understanding how this pipeline works is key if you want to get the most out of ASP.NET as an HTTP server platform, while making your process more efficient, and keeping your server secure. This article introduces the architecture of the pipeline and shows how you can use it to add sophisticated functionality to an ASP.NET-based app.

Web Q&A: Scripting Security

by Edited by Nancy Michell at 17:00 PM, 08/12/2002

Web Q&A: Scripting Security

The XML Files: WS-Security, WebMethods, Generating ASP.NET Web Service Classes

Cutting Edge: Using an Eval Function in Web Services

by Dino Esposito at 17:00 PM, 08/12/2002

Cutting Edge: Using an Eval Function in Web Services

There can be many reasons to reroute incoming Web requests. For instance, sometimes it's necessary to redirect a browser to a page based on user criteria without passing long lists of parameters in the URL. In the past, the only way to intercept such page requests and send them elsewhere was with ISAPI. Now, in ASP.NET, the IHttpModule interface provides notification of server requests, and lets you easily reroute them based on criteria other than browser type or version. Here the author demonstrates the use of IHttpModule for interception and explains the use of ISAPI filters for anyone who isn't yet using ASP.NET.

Web Q&A: Passing XML to SQL Server, Document.write on Resize, Transformations on the Fly, and More

The XML Files: Dynamic Discovery in .NET, Codebehind, WebService Inheritance, and More

One of the most significant features of ADO.NET is its integration with XML. Developers can either use an ADO-like API to access the data or work directly with an XML representation of the data. This article demonstrates how both of these techniques can be used together to create Web applications that take advantage of XML standards such as XSLT. The example presented here is a bug tracking application built using C# and the.NET Framework. The development of the application covers several topics including data access using ADO.NET, the presentation of data using XSLT stylesheets, and the integration of ADO.NET with the .NET XML Framework.

Web Q&A: HTML Table Control, WindowClosing Event, Numerous ActiveX Controls, and More

Pre-built custom controls make application design easier and faster and allow you to maintain UI consistency. However, prepackaged controls can be big and slow, and are OS-specific. For those who don't want to use prepackaged controls, Visual Studio .NET provides controls for Web Forms similar to those found in Windows Forms, including label and textbox, and new additions such as the DataGrid, all of which you can customize. If you want to design your own controls, the .NET Framework provides inheritable classes that take care of all the nasty stuff you want to avoid, including page lifecycle, maintaining state across invocations, and browser detection. This article discusses these concepts, as well as eventing, rendering, and client-side scripting.

Editor's Note: Scratching Out Web Bugs

by author at 17:00 PM, 05/13/2002

Editor's Note: Scratching Out Web Bugs

Web Q&A: XML Security Questions

by Edited by Nancy Michell at 17:00 PM, 05/13/2002

Web Q&A: XML Security Questions

The XML Files: WS-I, Exposing Stored Procedures as Web Services, and More

XML is becoming the ubiquitous data format on the Web, and XML support in SQL Server is evolving to meet the additional demand. Using XML, SOAP, HTTP, and SQL Server, you can now build powerful Web Services easily. To show just how simple it is with SQLXML 3.0, this article walks the reader through the process step by step, from setting up a virtual directory enabling data access via HTTP to executing queries and building Web Services. Finally, the author illustrates the creation of two Web Services clients-one with C# that works with the Microsoft .NET Framework and one with the SOAP Toolkit 2.0 for anyone still using earlier development tools.

Web Q&A: XML Data Islands, Updategrams, Stored Procedures, and More

by Edited by Nancy Michell at 17:00 PM, 04/15/2002

Web Q&A: XML Data Islands, Updategrams, Stored Procedures, and More

The ASP Column: HTTP Modules

by George Shepherd at 17:00 PM, 04/15/2002

The ASP Column: HTTP Modules

Global.asax events

  • Application Events
    • void Application_Start(Object sender, EventArgs e) {}
    • void Application_End(Object sender, EventArgs e) {}
    • void Application_BeginRequest(Object sender, EventArgs e) {}
    • void Application_AuthenticateRequest(Object sender, EventArgs e) {}
    • void Application_PostAuthenticateRequest(Object sender, EventArgs e) {}
    • void Application_AuthorizeRequest(Object sender, EventArgs e) {}
    • void Application_PostAuthorizeRequest(Object sender, EventArgs e) {}
    • void Application_ResolveRequestCache(Object sender, EventArgs e) {}
    • void Application_PostResolveRequestCache(Object sender, EventArgs e) {}
    • void Application_AcquireRequestState(Object sender, EventArgs e) {}
    • void Application_PostAcquireRequestState(Object sender, EventArgs e) {}
    • void Application_PreRequestHandlerExecute(Object sender, EventArgs e) {}
    • void Application_PostRequestHandlerExecute(Object sender, EventArgs e) {}
    • void Application_ReleaseRequestState(Object sender, EventArgs e) {}
    • void Application_PostReleaseRequestState(Object sender, EventArgs e) {}
    • void Application_UpdateRequestCache(Object sender, EventArgs e) {}
    • void Application_PostUpdateRequestCache(Object sender, EventArgs e) {}
    • void Application_EndRequest(Object sender, EventArgs e) {}
    • void Application_Disposed(Object sender, EventArgs e) {}
    • void Application_Error(Object sender, EventArgs e) {}
    • void Application_PreSendRequestContent(Object sender, EventArgs e) {}
    • void Application_PreSendRequestHeaders(Object sender, EventArgs e) {}
  • Session Events
    • void Session_Start(Object sender, EventArgs e) {}
    • void Session_End(Object sender, EventArgs e) {}
2008 scandalz.net
"Rembrandt's first name was Beauregard, which is why he never used it." -- Dave Barry
CountryUS
IP Address38.103.63.59
User AgentCCBot/1.0 (+http://www.commoncrawl.org/bot.html)