ASP.NET Web Pages Templates for VB

Today, (well…yesterday, but I didn’t have time to blog about it yesterday) our team added the Visual Basic versions of the templates you can get inside of WebMatrix for ASP.NET Web Pages.  These are available as NuGet packages on the NuGet Gallery site.

Along with the above 4 templates we’ve also shipped the original 4 C# templates that are included in WebMatrix as packages for those of you who might use ASP.NET Web Pages without WebMatrix.

In this release, we’ve also included a new template that doesn’t ship (yet) in WebMatrix.

To run these templates, simply open an existing or create a new ASP.NET Web Pages app and navigate to (or click the “ASP.NET Web Pages Administration” link on your dashboard in WebMatrix), login to the admin, search for “template”, pick which package you want and install it.  This will put the contents of the template into a folder called “Microsoft Templates” in your app root.  Inside will be instructions to tell you to take the contents of that folder and move them to the root of your site.  This step is unfortunate, but required since NuGet or the ASP.NET Web Pages Administration app doesn’t currently allow you to override existing files.  Now run your site and you should see the template you installed.

Jim Wang, who works on our team (and built the WishList Template), made a video on how to get WishList installed in less than a minute.

We hope these are helpful to get you started with ASP.NET Web Pages!  For those of you working with VB, we want to hear from you.  Are these templates helpful?  Anyone running ASP.NET Web Pages WITHOUT WebMatrix (or Visual Studio)?

IE 9 Windows Jump List ASP.NET Web Pages Helper

I’m sure you’ve all heard today about the beta release of IE 9.  It’s looking pretty good!  Did you see that you can integrate with the Windows Jump List now?  Neato!  Neowin has a write up on the meta tags you need to have to integrate with Windows.  Over lunch I wrote a quick helper in ASP.NET Web Pages (install WebMatrix via WebPI here) that you can just drop into your App_Code folder…

Code Snippet
using System;
using System.Web;
using System.Web.Mvc;
using Microsoft.WebPages.Helpers;

public static class Windows {
    public static IHtmlString JumpListTask(string name, string actionUrl, string iconUrl) {
        HttpContext httpContext = HttpContext.Current;
        if (httpContext.Request.Browser.Browser == "IE" && httpContext.Request.Browser.Version.StartsWith("9")) {
            if (string.IsNullOrWhiteSpace(name)) {
                throw new ArgumentNullException("name");
            if (string.IsNullOrWhiteSpace(actionUrl)) {
                throw new ArgumentNullException("actionUrl");

            if (string.IsNullOrWhiteSpace(iconUrl)) {
                throw new ArgumentNullException("iconUrl");

            if (!(actionUrl.StartsWith("http://") || actionUrl.StartsWith("https://"))) {
                string hostUrl = httpContext.Request.Url.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped);
                actionUrl = hostUrl + VirtualPathUtility.ToAbsolute(actionUrl);

            TagBuilder html = new TagBuilder("meta");
            html.MergeAttribute("name", "msapplication-task");
            html.MergeAttribute("content", string.Format("name={0}; action-uri={1}; icon-uri={2}", name, actionUrl, iconUrl));

            return new HtmlString(html.ToString(TagRenderMode.SelfClosing));
        return new HtmlString("");

And then call it in your page…

<!DOCTYPE html>
        @Windows.JumpListTask("Test", "~/", "fav.ico")

Not much to it, but hopefully some of you will find it handy.  Note: it does not render anything in browsers other than IE 9.  Maybe we can clean this up and put it in the next release of ASP.NET Web Pages.  :)  What do you think?  Do you have other ideas for helpers in ASP.NET Web Pages?