Tom Archer's Blog

Windows and Web developer with Social Media tendencies

View Components in ASP.NET 5

ASP.NET 5 View Components – like ASP.NET Partial Views – enable you to create a kind of mini-controller capable of rendering a partial response to the client rather than a whole response. This is especially useful for situations where you want to display some dynamic data to your user on multiple pages. For example, a store app could display it’s best selling or on-sale items on every page with links to a Deals page. An LOB app might need the ability to display system warnings on each page. This post is a quick introduction to how to set up and use a View Component in ASP.NET 5.

To add a View Component to an ASP.NET 5 app, simply follow these steps:

  1. Create the View Component
  2. Create the View Component’s view
  3. Call the Component.Invoke

Create the View Component

To create a View Component, first create a C# class and either derive it from ViewComponent or decorate it with the ViewComponent attribute.

using Microsoft.AspNet.Mvc;

namespace MyStore.Models
  public class User
    public string Name { get; set; }

  public class UsersOnline : ViewComponent
    public IViewComponentResult Invoke ()
      // In-memory structure to keep example simple.
      // In a real-world app, this data would come from a 
      // data store such as a database.
      IList<Item> users = new List<User>()
        new User() { Name = "Krista" }
        new User() { Name = "Tom" }

      return View(users);

Create the View Component’s view

Next, create the view that will be displayed when the View Component is rendered.

@model IEnumerable<MyStore.Models.User>

<h3>Other online users</h3>
@foreach (var user in Model)

Call Component.Invoke

The last step is to call the Component.Invoke method wherever you want to display the View Component.



View Components are just one of the many new great features in ASP.NET 5 that make your coding life just a little bit easier. Check out the for more detailed articles on this feature any many others.

Related Links


September 26, 2015 Posted by | aspnet5 | Leave a comment

Mapping a Network Drive to a SkyDrive in Windows 8

Many times, I want to access my SkyDrive files from Windows Explorer or a command prompt as I would any other network location – instead of having to go through the SkyDrive Metro UI. Here’s how easy it is to do that:

  1. Go to the Windows 8 start screen.
  2. Click the SkyDrive icon.
  3. In SkyDrive, open a document – such as an Excel or Word document.
  4. In the document’s editor, go to Save->File As.
  5. Note the folder name at the top of the Save-As dialog. It should read something like{user-id}/Documents.
  6. Copy the save-as location to the clipboard. Note: You might have several folders in your SkyDrive folder hierarchy. Copy to the clipboard the part of the path that makes sense to you. For example, I use{user-id} so that I can get at all of my files and folders.
  7. You can close the Save-As dialog and the document if you wish as they’re no longer needed for this task.
  8. Open Windows Explorer.
  9. Click Map Network drive on the toolbar.
  10. When the Map Network Drive dialog appears, select an available drive letter, and paste the SkyDrive path into the Folder textbox.
  11. Click Finish.
  12. You should now be able to access your SkyDrive files and folders from the drive letter you entered.

June 4, 2013 Posted by | Uncategorized | Leave a comment

Bing Visual Search for Windows PowerShell cmdlets!

We now have a Windows PowerShell Cmdlets gallery in Bing Visual Search that includes all of the core cmdlets! Using Bing’s “narrow by” options, you can quickly filter by Verb, Noun, version in which the cmdlet was introduced, parameter, and much more! As Microsoft Distinguished Engineer Jeffrey Snover says in this YouTube video, Bing and Windows PowerShell “go together like peanut butter and jelly…just beautiful”.

May 12, 2010 Posted by | PowerShell | Leave a comment

Moving into the PowerShell (Run)Space!

For the past year, I’ve been a Programmer/Writer for Windows Server Update Services (WSUS), Windows Update Agent (WUA), and Group Policy. While most of my work dealt with the APIs specific to those technologies, I also found time and opportunity to work with Windows PowerShell.

While I’ve enjoyed working with WSUS and Group Policy, I’m excited to announce that – starting today – I am the Programmer/Writer responsible for the PowerShell SDK! In that capacity, I’ll be writing example code and conceptual topics for MSDN. This includes explaining how to code PowerShell cmdlets, providers, host applications, and much more. Therefore, the most logical place to start my blogging about my new responsibilities would be to explain what PowerShell is.

The canonical definition is that Windows PowerShell is a command-line shell built on top of the .NET framework designed to provide an extensible environment to automate administrative tasks on local and remote Windows systems using cmdlets (pronounced “command-lets”) which are simple, single-function command-line tools built into the shell. However, there’s much more to it than that. Windows PowerShell is also the runtime behind the shell. The shell is simply a “host application” that interfaces to the Windows PowerShell runtime. As a result of this design, you could very well write your own host application that enables your users to leverage PowerShell’s scripting language! Designing and coding cmdlets and hosting applications as well as providers and using the scripting language itself are just a few of the topic that I’ll be covering in this space. Hopefully by doing so, I’ll help others to shorten their own learning curves as they master this incredibly robust environment.

For those of you new to Windows PowerShell, here are some great topics/links to get you started:

May 10, 2010 Posted by | PowerShell | Leave a comment

[Video] Kim Field and the Mighty Titans of Tone

Kim Field is a highly-respected Director in the Windows Server UA organization. In fact, he was one of the people that interviewed me when I came over to this org! So, when I heard that Kim was the lead vocalist for a blues band called the Mighty Titans of Tone and that they were playing a gig in Seattle, I figured that I would show up mainly just to support a co-worker’s endeavor and duck out a bit early.

Much to my surprise, what I found instead was a real treat. Not only was the band top-notch, but Kim’s vocals and harmonica play far exceeded anything I could have expected. In fact, I later read that the Seattle Times wrote of Kim’s play, “The finest blues harmonica player in the Northwest”. From Option Magazine, “Some of the smoothest harmonica work you will ever hear”. After hearing Kim and his band play, I have to say that these reviewers were spot on. Not only is he a great frontman in terms of talent, but he also has a wonderful on-stage presence and easily jokes with the members of the audience. One moment I remember in particular was a heart-warming Frank Sinatra cover that he dedicated to his parents who were in attendance.

All in all, it was a memorable evening of rhythm and blues. I highly recommend that you take the opportunity to see Kim Field and the Mighty Titans of Tone play live if you have the opportunity. You will not be disappointed. Until then, here are some songs that I captured with my FlipVideo. Enjoy and don’t forget to visit the band’s calendar to see where they’re playing next!

July 28, 2009 Posted by | Music | 1 Comment

New Job at Microsoft!

I started my new job this week! I am a “Programmer/Writer” within the MSD (Managed Solutions Division) org. So first, what is a “Programmer/Writer” and what responsibilities does that role entail? In broad terms, a Programmer/Writer (also called a Programming Writer) is a technical person that writes code samples and documentation for a developer audience. The cool thing about this job is that I get to do two things I enjoy very much: coding and writing. Coming from a coding background, I especially like the fact that I can code now without worrying about the drudgery of being a line coder where once you’ve learned a new technology or framework, you’re now doing the same thing over and over. In my new job, once I’ve documented something and written code samples for it, I move on to the next cool thing to learn and document!

So what am I documenting? I’m responsible for Group Policy and Windows Server Update Services. Specifically, I’ll be writing the example code and documetation for the Group Policy Powershell cmdlets! Very cool stuff indeed 🙂

May 6, 2009 Posted by | 1 | 4 Comments

Winning Streaks – Part One

While this might be yet another indicator of me getting old, I could swear that there was an expression I heard as a child that went something like “whenever a team on a winning streak stubs its toe, it almost always falls on its face”. Come to think of it, if that was the expression, it’s pretty easy to see why it didn’t take. It’s not exactly pithy. At any rate, the point of the (possibly mythical) expression – and this post – is that I find it amazing that when an individual or team goes on a long winning streak and then finally loses, they almost always lose a second straight regardless of the relative strength of the second opponent. I find this amazing as logically I would think that the individual or team would bounce back – especially if the second opponent is much weaker – and return to playing at the same level that resulted in the winning streak.

One example of this is the NBA Houston Rockets who won 22 consecutive games during the 2007/2008 season.  Once the second longest winning streak in the history of the NBA was finally stopped by the Boston Celtics, the Rockets then lost to the New Orleans Hornets. While hardly a major upset considering that the Hornets ended the campaign as the second seeded Western Conference team, what’s noteworthy is that after a month of incredible play, the Rockets played terribly in the second loss. The Rockets then went back to their winning ways by capturing 3 out of their next 4 games.

The 2008/2009 NBA season offers us another example where the Boston Celtics made their pitch for immortality in a pursuit of the almost inconceivable 33-game winning streak of the 1971/1972 Los Angeles Lakers. The men in green ran their streak to 19 games before bowing to the Los Angeles Lakers on Christmas Day 2008. They then served up a real turkey of a game in losing to one of the league’s doormats – the Golden State Warriors, who had won all of 8 games over the first third of the season.

As is often the case, what got me to thinking about this was my own personal experience. I had won 13 straight APA (American Pool Association) 8-ball matches before playing the man who is arguably the best 8-ball player in our league. I played well – not great – and lost by a single shot. The following week, I played someone – who while being very talented – I had defeated all 5 times I had played him previous. As you can probably guess, I played very poorly (relative to how I had been playing for the previous several months) and lost a close match. Once those two losses were out of the way, I played well again and have won my last two matches.

While my situation is on a much less global scale than an NBA team, my experience is an example of what I believe I’ve noticed most of my life as a both a competitor and sports fan. However, all of this is very anecdotal and far from scientific. Therefore, I’m going to write a little code to parse the schedules and results of several major sports in order to determine if this phenomenon actually exists. Once I do that, I’ll post a follow-up article!

(If you have any information on this or pointers to research already being done, please email me – !)

Tom Archer

December 27, 2008 Posted by | 1 | Leave a comment

Free Access 2007 tutorial by Crystal Long

Crystal Long - Access MVPCrystal Long – Access MVP – has published a 100-page tutorial on Access that she makes freely available to everyone! This 8-part series covers everything from database design basics and normalization to form and report design. Here are some tips from Crystal herself on getting the most out of this wonderful resource.

“To get the most out of ‘Access Basics’, try to clear your mind of your immediate needs and focus, instead, on generalities… otherwise you may skim over essentials that you see no immediate application for…

Print it out and read it once a week. As you read, use a highlighter for things you want to emphasize. Put ‘?’ in the margins of paragraphs that you skip or don’t make sense with a pencil. Each time you read it, erase the pencil marks as you understand.

Also, copy the chapter files to your hard drive and follow each one of the links — to familiarize yourself with other available resources.“

It is this sort of activity that makes Crystal such a valuable resource in the Access technical community and one of many reasons that we’re proud to count her as an MVP.

September 21, 2008 Posted by | Access, Microsoft MVP Program | 3 Comments

Beware of UPS Virus!

The latest virus making the rounds is the ‘UPS Delivery Failure’.

With this virus, unwitting victims receive an email from the “UPS Packet Service” along with an alleged packet number.

The mail will claim to be from UPS and will explain that UPS was unable to deliver a package to you. You are requested to print the attached invoice.


Opening or attempting to print the attachment will launch the virus.

Please inform anyone in your social/work circle about this virus as it has already caused millions of dollars in damage.

Note that this has been verified via the Snopes Web site

September 18, 2008 Posted by | Security, Virus | Leave a comment

Local Women’s 8-ball Tourney

Krista playing Randi Sue
Had a great time today watching Krista (my better half) play in only her second tourament – a local women’s 8-ball tournament in Valhalla (Kirkland, WA). Krista is currently a 2 in 8-ball so her first match against Mary (a strong 4) was a 2-4 race. She won the first game with some very nifty shot-making and came very close to winning each of the next two games. Ultimately, she fell 1-4 and moved to the loser’s bracket.

On the losers side, she ran into dear friend and very good 8-ball player (SL5) Randi Sue Andrews. Once again, Krista took the first game and was immediately on the hill. However, Randi Sue is a veteran player with many years of tournament experience under her belt so she wasn’t fazed and took the match 1-5.

All in all, a great showing for Krista as she has less than a year of pool experience and had a couple of nice 4 ball runs. Great job, Krista!! You can see many of the photos I took on my Facebook.

September 14, 2008 Posted by | 1 | , | 1 Comment