Scott Hanselman

How to access NuGet when NuGet.org is down (or you're on a plane)

March 09, 2012 Comment on this post [29] Posted in NuGet | Open Source
Sponsored By

I was in Dallas today speaking at the Dallas Day of .NET. During my keynote presentation - it included lots of NuGet demos - and for some reason the NuGet.org site was down at that exact moment. I ended up coming up in the middle somewhere. I'm not in Redmond so I don't know what happened and I won't speak for the team. However, my initial reaction was "I'm screwed" and the crowd was interested in how I was going to continue. We all depend on NuGet (the system) and NuGet.org (the server). I know that the team is aiming for "5 nines" availability with the NuGet.org site and that it runs in Azure now. I assume they'll put an explanation of the issue up on the site soon.

Regardless, you might think I was stuck. Well, remember that NuGet caches the packages it downloads on your local hard drive. My cache was located at C:\Users\scottha\AppData\Local\NuGet\Cache.

The Local NuGet Package Cache

You can add that cache folder as a NuGet Source by going to Options | Package Manager | Package Sources. You can see I added it in my dialog below.

The NuGet Package Source Options dialog

Then later, when I'm using NuGet offline I can select my cache if need be. Again, I should never need to, but you get the idea:

The NuGet Cache selected as an option in the Package Manager Console 

If you're concerned about external dependencies on a company-wide scale, you might want to have a network share (perhaps on a shared builder server) within your organization that contains the NuGet packages that you rely on. This is a useful thing if you are in a low-bandwidth situation as an organization.

If you think a feature that makes offline a more formal state is useful, please go vote up this "offline" issue on NuGet's CodePlex site and join the conversation with ideas on how you think "NuGet on an airplane" or "low/no bandwidth NuGet" should work. For example, should it automatically fall back? Should there be a timeout? Should there by an -offline explicit option? Should the existing Offline Cache be added automatically?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Dark Matter Developers: The Unseen 99%

March 07, 2012 Comment on this post [101] Posted in Musings
Sponsored By

In astronomy and cosmology, dark matter is a currently-undetermined type of matter hypothesized to account for a large part of the mass of the universe, but which neither emits nor scatters light or other electromagnetic radiation, and so cannot be directly seen with telescopes. - Wikipedia on Dark Matter

You can't see dark matter, but we're pretty sure it's there. Not only is it there, but it's MOST of what's there. We know it and we can't see it. It never shows up.

My coworker Damian Edwards and I hypothesize that there is another kind of developer than the ones we meet all the time. We call them Dark Matter Developers. They don't read a lot of blogs, they never write blogs, they don't go to user groups, they don't tweet or facebook, and you don't often see them at large conferences. Where are these dark matter developers online?

Part of this is the web's fault. The web insists on moving things forward at an rate that makes people feel unable to keep up. I mean, Google Chrome has upped two version numbers just in the last 3 paragraphs of this blog post. Microsoft probably created a new API and deprecated an old one just while I was typing this sentence.

Lots of technologies don't iterate at this speed, nor should they. Embedded developers are still doing their thing in C and C++. Both are deeply mature and well understood languages that don't require a lot of churn or panic on the social networks.

Where are the dark matter developers? Probably getting work done. Maybe using ASP.NET 1.1 at a local municipality or small office. Maybe working at a bottling plant in Mexico in VB6. Perhaps they are writing PHP calendar applications at a large chip manufacturer.*

Personally, as one of the loud-online-pushing-things-forward 1%, I might think I need to find these Dark Matter Developers and explain to them how they need to get online! Join the community! Get a blog, start changing stuff, mix it up! But, as my friend Brad Wilson points out, those dark matter 99% have a lot to teach us about GETTING STUFF DONE.

They use mature products that are well-known, well-tested and well-understood. They aren't chasing the latest beta or pushing any limits, they are just producing. (Or they are just totally chilling and punching out at 5:01pm, but I like to think they are producing.) Point is, we need to find a balance between those of us online yelling and tweeting and pushing towards the Next Big Thing and those that are unseen and patient and focused on the business problem at hand.

I like working on new stuff and trying to new ways to solve old (and new) problems but one of the reasons I do like working on the web is that it's coming to a place of maturity, believe it or not. I feel like I can count on angle brackets and curly braces. I can count on IL and bytecode. These are the reliable and open building blocks that we will use to build on the web for the next decade or three.

While some days I create new things with cutting edge technology and revel in the latest Beta or Daily Build and push the limits with an untested specification, other days I take to remember the Dark Matter Developers. I remind my team of them. They are out there, they are quiet, but they are using our stuff to get work done. No amount of Twitter Polls or Facebook Likes or even Page Views will adequately speak for them.

The Dark Matter Developer will never read this blog post because they are getting work done using tech from ten years ago and that's totally OK. I know they are there and I will continue to support them in their work.

* These people and companies all exist, I've met them and spoken to them at length.

UPDATE: I found a blog post from John Cook that mentioned Kate Gregory who also used this term "Dark Matter" to refer to programmers. It seems it's an apt analogy!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

On the nightmare that is JSON Dates. Plus, JSON.NET and ASP.NET Web API

March 06, 2012 Comment on this post [69] Posted in ASP.NET | Javascript | Open Source
Sponsored By

Ints are easy. Strings are mostly easy. Dates? A nightmare. They always will be. There's different calendars, different formats. Did you know it's 2004 in the Ethiopian Calendar? Yakatit 26, 2004, in fact. I spoke to a German friend once about how much 9/11 affected me and he said, "yes, November 9th was an amazing day in Germany, also."

Dates are hard.

If I take a simple model:

public class Post
{
public int ID { get; set; }

[StringLength(60)][Required]
public string Title { get; set; }

[StringLength(500)]
[DataType(DataType.MultilineText)]
[AllowHtml]
public string Text { get; set; }

public DateTime PublishedAt { get; set; }
}

And I make a quick ASP.NET Web API controller from VS11 Beta (snipped some stuff for simplicity):

public class PostAPIController : ApiController
{
private BlogContext db = new BlogContext();

// GET /api/post
public IEnumerable<Post> Get()
{
return db.Posts.ToList();
}

// GET /api/post/5
public Post Get(int id)
{
return db.Posts.Where(p => p.ID == id).Single();
}
...snip...
}

And hit /api/post with this Knockout View Model and jQuery.

$(function () {
$("#getPosts").click(function () {
// We're using a Knockout model. This clears out the existing posts.
viewModel.posts([]);

$.get('/api/PostAPI', function (data) {
// Update the Knockout model (and thus the UI)
// with the posts received back
// from the Web API call.
viewModel.posts(data);
});
});

viewModel = {
posts: ko.observableArray([])
};

ko.applyBindings(viewModel);
});

And this super basic template:

<li class="comment">
<header>
<div class="info">
<strong><span data-bind="text: Title"></span></strong>
</div>
</header>
<div class="body">
<p data-bind="date: PublishedAt"></p>
<p data-bind="text: Text"></p>
</div>
</li>

I am saddened as the date binding doesn't work, because the date was serialized by default like this. Here's the JSON on the wire.

[{
"ID": 1,
"PublishedAt": "\/Date(1330848000000-0800)\/",
"Text": "Best blog post ever",
"Title": "Magical Title"
}, {
"ID": 2,
"PublishedAt": "\/Date(1320825600000-0800)\/",
"Text": "No, really",
"Title": "You rock"
}]

Eek! My eyes! That's milliseconds since the beginning of the Unix Epoch WITH a TimeZone. So, converting in PowerShell looks like:

PS C:\> (new-object DateTime(1970,1,1,0,0,0,0)).AddMilliseconds(1330848000000).AddHours(-8)

Sunday, March 04, 2012 12:00:00 AM

Yuck. Regardless,  it doesn't bind with KnockoutJS either. I could add a bindingHandler for dates like this:

ko.bindingHandlers.date = {
init: function (element, valueAccessor, allBindingsAccessor, viewModel) {
var jsonDate = valueAccessor();
var value = new Date(parseInt(jsonDate.substr(6)));
var ret = value.getMonth() + 1 + "/" + value.getDate() + "/" + value.getFullYear();
element.innerHTML = ret;
},
update: function (element, valueAccessor, allBindingsAccessor, viewModel) {
}
};

That works, but it's horrible and I hate myself. It's lousy parsing and it doesn't even take the TimeZone into consideration. This is a silly format for a date to be in on the wire.

Example of Knockout binding

I was talking to some folks on Twitter in the last few days and said that all this is silly and JSON dates should be ISO 8601, and we should all move on. James Newton-King the author of JSON.NET answered by making ISO 8601 the default in his library. We on the web team will be including JSON.NET as the default JSON Serializer in Web API when it releases, so that'll be nice.

I mentioned this to Raffi from Twitter a few weeks back and he agreeds. He tweeted back to me

He also added "please don't do what the @twitterAPI does (ruby strings)." What does that look like? Well, see for yourself: https://www.twitter.com/statuses/public_timeline.json in a random public timeline tweet...snipped out the boring stuff...

{
"id_str": "176815815037952000",
"user": {
"id": 455349633,
...snip...
"time_zone": null
},
"id": 176815815037952000,
"created_at": "Mon Mar 05 23:45:50 +0000 2012"
}

Yes, so DON'T do it that way. Let's just do it the JavaScript 1.8.5/ECMASCript 5th way and stop talking about it. Here's Firefox, Chrome and IE.

All the browsers support toJSON()

We're going to do this by default in ASP.NET Web API when it releases. (We aren't doing this now in Beta) You can see how to swap out the serializer to JSON.NET on Henrik's blog. You can also check out the Thinktecture.Web.Http convenience methods that bundles some useful methods for ASP.NET Web API.

Today with the Beta, I just need to update my global.asax and swap out the JSON Formatter like this (see Henrik's blog for the full code):

// Create Json.Net formatter serializing DateTime using the ISO 8601 format
JsonSerializerSettings serializerSettings = new JsonSerializerSettings();
serializerSettings.Converters.Add(new IsoDateTimeConverter());
GlobalConfiguration.Configuration.Formatters[0] = new JsonNetFormatter(serializerSettings);

When we ship, none of this will be needed as it should be the default which is much nicer. JSON.NET will be the default serializer AND Web API will use ISO 8601 on the wire as the default date format for JSON APIs.

ISO Dates in Fiddler

Hope this helps.


Sponsor: Big thanks to DevExpress for sponsoring this last week's feed. There is no better time to discover DevExpress. Visual Studio 11 beta is here and DevExpress tools are ready! Experience next generation tools, today.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

How To Guide to Installing and Booting Windows 8 Consumer Preview off a VHD (Virtual Hard Disk)

March 01, 2012 Comment on this post [69] Posted in Win8
Sponsored By

The Windows 8 BootloaderSo Windows 8 Consumer Preview is out today. You probably read the Windows 8 Consumer Preview Announcement by Steven Sinofsky and then rushed off to Download it.

Disclaimer: Hopefully you are a technical person or you are not afraid of totally destroying your computer with new preview software. Even better, you aren't the kind of person to rage on a stranger's blog when his totally unsupported instructions on how to install the Windows 8 Consumer Preview onto a VHD delete everything you know an love. You're on your own, friend. I don't work for the Windows team and you don't know me. Remember that as you edit your boot records and destroy your PhD thesis. To the cloud!

First, what's the idea here? I'm assuming that:

  • You want to try out Windows 8 on your machine
  • You don't want to take any chance with dual booting or getting a slower experience inside a regular Virtual Machine.

Cool. If you have Windows 7 now then you can "boot to a virtual hard disk (VHD)" and get all the loveliness of Windows 8 running on hardware without any risk to your hard drive. Don't like it? Delete the VHD and update your boot record.

HUH? What does this mean? What this means is that ONLY the Hard Drive will be virtualized. Your Windows 8 system will run ON THE HARDWARE with your real video card, real CPU, real network card, etc. However, it will NOT run directly from your hard drive - it will run from a file on your hard drive. Windows 8 will live and run on its own personal "virtualized hard drive" which is the VHD.

Ok, now that that disclaimer and expectation setting is done. I don't work for the Windows team, and you don't know me. I am just a guy who loves Boot to VHD. I wrote the Guide to Installing and Booting Windows 8 Developer Preview off a VHD (Virtual Hard Disk) that you may have used last year to play with the build of Windows 8 that was released at the BUILD conference.

Updating from Developer Preview? Delete and start over!

If you want to now try using the Windows 8 Consumer Preview and you already have a VHD setup with the Developer Preview from last year, you can simply delete the existing VHD from your hard drive, then run "msconfig.exe" as administrator and delete the existing boot entry as seen in this screenshot.

Then just setup a new VHD all over again for this new Consumer Preview version of Windows 8. That's the magic of boot to VHD. You can just remove the VHD. You can even have multiple versions if you have the disk space. Just make sure your boot record is up to date.

MSConfig and the GUI Boot Manager

Setting up Boot to VHD

Works on My Machine BadgeThe original instructions on how to boot Windows 8 from a VHD still work and are valid for the Consumer Preview. They work on my machine. I did want to slightly update the post with additional information with the help of a number of people internally with some techniques that may make things easier for you. Thanks to Iain and friends.

Why Boot to VHD?

I boot to VHD all the time. It works great, and the idea of booting to some VHD is a supported thing to be doing on Windows 7. Boot to VHD is a great actual feature of Windows 7 and Windows 8.  Why do it?

I could do a few things to work with Windows 8. I could:

  • Try a virtualization solution, but it might not work, I may not have the drivers I need and it won't be as shiny as running "on the metal."
    • In fact, the Windows 8 team says this:  "Our recommendation for the Consumer Preview is to run it natively on hardware if you intend to run Windows 8 on hardware when the product is final. Some of you will run virtualized environments for enterprise workloads or specialized purposes, but we strongly recommend that you experience Windows 8 on hardware, as it was designed to run for the majority of consumer experiences. "
  • Sacrifice a machine I have lying around. I'll probably do that at some point, but I'd like to try it out on my actual hardware that I use all day long.
  • Swap out my C: drive and use my main machine. I don't have a tool-less case, and I'm also very lazy, so, um, ya.
  • Dual boot. Dual booting may feel ninja but it ALWAYS ends on tears. And sometimes blood.
  • Boot on real hardware from a Virtual Hard Disk

It's that last option that is the best one, in my opinion. Windows 7 included the ability to boot windows from a Virtual Hard Disk File (.vhd). You can read more about the Windows 7 VHD boot capability and recommendations from the TechNet article here. The Windows  8 developer preview was downloaded millions of times and the word on the street is that there was a huge increase in installations in virtualized environments. I think booting to VHD is way better than installing in a truly Virtual Machine because it allows Windows 8 (and you) to really access the native hardware and shine.

Requirements (read these!)

Here's the requirements if you want to try this.

  1. You will need to be an Administrator on your Windows 7 system
  2. You will likely need at least 40gb free disk space on the volume that the VHD is going to be stored. As you're likely creating your own VHD and installing Windows 8 Consumer Preview on it, then you will need free space at least equal to the virtual disk size of the VHD that was created
  3. Boot VHDs need to be on an internal drive. USB drives won’t work.
  4. If your system has Bitlocker enabled, you need to suspend Bitlocker while editing boot settings
  5. More importantly, READ THE WINDOWS 8 CONSUMER PREVIEW FAQ!

Get Started

If you like doing things manually, you should directly the Windows 8 Consumer Preview ISO. I'd recommend burning Windows 8 Consumer Preview to a DVD or a USB Flash drive so you can easily install it on other machines easily. You can certainly do other ISO mounting tricks with other tools if you want to, but honestly it's just cleaner and easier to go download the Windows 8 Consumer Preview ISO and do it the regular way. There's less moving parts and all that.

From their site:

How to install Windows 8 Consumer Preview from an ISO image

The easiest way to convert an ISO file to a DVD in Windows 7 is to use Windows Disc Image Burner. On a PC running Windows XP or Windows Vista, a third-party program is required to convert an ISO file into installable media—and DVD burning software often includes this capability. One option is the USB/DVD download tool provided by the Microsoft Store. You can also download Windows 8 Consumer Preview Setup, which includes tools that allow you to create a DVD or USB flash drive from an ISO file (Windows Vista or Windows 7 required).

Take the Leap

Read the disclaimer at the top again. I don't know you and you're installing Beta software. .

Here's the general idea in broad strokes. The tiny details we'll be following are on my Guide to Installing and Booting Windows 8 off a VHD (Virtual Hard Disk).

  • First:  Go Get the Windows 8 Consumer Preview Download

  • Remember: Have a lot of disk space (40gigs or more)

  • Either burn your downloaded ISO to a DVD or make bootable USB Key manually.

  • Create a VHD that you will attach and install Windows 8 into

  • Boot your system of your newly created Windows 8 Consumer Preview DVD or USB Key

  • Attach your VHD during the setup process

  • Select your VHD as the hard drive to install to (make very sure you know where you're installing to)

  • Reboot and pick your operating system with the new lovely Windows 8 boot manager.

Alright. Sound good? You have some bootable media (DVD/USB) all setup with Windows 8 Consumer Preview? Now head over to my original post and start at Step 2. Fun!


Covering your Tush

If you want to be super careful you can backup your Boot Manager Database to a safe place by doing this from an Administrator Command Prompt:

BCDEDIT /export c:\bcdbackup.bak

and if you totally mess things up and you want to put things back the way they were, you can

BCDEDIT /import c:\bcdbackup.bak

Then delete the VHD and and reboot your system. If any of this is scary or you don't know what you're doing, then just stop and go here now.

FAQ

But I use the LILO (LInux LOader) or GRUB (Grand Unified Bootloader).Boot loader

By running the BCDBOOT command, you’ll set the Windows Boot Manager writes the entry to the Master Boot Record (MBR) of system as the default. A system can only have one Boot manager at a time.

If you want to revert to your previous boot loader, just follow that software’s normal installation instructions.

I've heard some reports of GRUB supporting .VHD boot, but we have not tested it. You're on your own.

Can I do this on a Mac?

No. Apple MacOS uses Unified Extensible Firmware Interface (UEFI) which locks the Guid Partition Table (GPT). The GPT holds a similar position in the UEFI systems as MBR for the BIOS systems.

Why does the VHD need so much space?

VHDs are created as dynamically expanding by default, up to 40gb which get expanded to their full size when used as a boot disk. Some people like them to be even bigger.

Note: The reason why the boot VHD gets expanded to its maximum size run running is to avoid the case where the hosting volume runs out of space when it is being actively being used as a system disk. If the hosting volume does run out a space, it would result in an unexpected system reboot. The user would need to boot into an alternate OS or recovery partition to free up space on the hosting volume before he can boot into the VHD again.

Can I use some other tools to do this?

There are a number of tools that do things like bcdedit in a graphical environment. I like Bellavista which I have used on Windows 7. However, do note that I did not test or run the steps above using anything but the tools in Windows.

--

Hope this helps you have fun testing Windows 8 Consumer Preview in a safe way.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Visual Studio 11 Beta in Context

March 01, 2012 Comment on this post [53] Posted in ASP.NET | ASP.NET MVC | Microsoft
Sponsored By

Today Visual Studio 11 Beta is released and available for download. Don't want to read a big blog post? Phooey on you then! ;)

Made it this far? OK, cool. I wanted to do a post that would not only point you to a bunch of other resources, but more generally answer the obvious questions. The questions that I asked before I went to work for Microsoft four years ago. I always ask: What's changed, and why should I care?

"One ASP.NET"

One of the things that the fellows and I are working on that will be more obvious  after the beta and even a little after the final release is this idea of One ASP.NET. We're sweeping through the whole framework, samples, templates and NuGet to make sure things work together cohesively. You'll hear more about this as we firm it up.

Some guiding principles for ASP.NET are these:

  • Every reasonable combination of subsystems just works
  • The model is easily extended by community projects (not just us!)
  • Every subsystem or application type includes a *.Sample that works together with others

Here's the boxes diagram I've been playing with.

These principles are some of the things that drove (and continue to drive) ASP.NET this development cycle. We are trying to give you great mobile options, great HTML5, CSS3 and JavaScript support and also including open source libraries like Modernizr, jQuery, jQuery UI and Knockout.

We are working towards a more pluggable, more friendly but still powerful ASP.NET. Again, more on this soon and some surprises. We'll see more interesting uses of NuGet, more plug-ablity, more examples, and more systems working together.

You want to mix and match a ASP.NET Web API, serialization with JSON.NET, use MongoDB, run Web Pages and Web Forms side by side, add some some SignalR and a few WCF enterprise Web Services? Add in ELMAH, Glimpse, Image Resizer and your favorite NuGet packages? Totally. It's Encouraged. It's all One ASP.NET.

.NET Framework 4.5 Beta

For the most part in my experience, .NET 4.5 is a very compatible release. .NET 4.5 upgrades .NET 4 as .NET 3.5 upgraded .NET 3 (and 2, although we're trying to play by the versioning rules now, thank goodness.) The vast majority of .NET 4 apps should work fine on .NET 4.5 unless you are doing something exotic. I haven't had any problems myself, but I've heard of some unusual edge cases with folks doing ILMerge and a few other things.

There's a number of new improvements. Some of my personal favorites and features I'm most interested in are (these are somewhat obscure, but nice fixes, IMHO):

  • Ability to limit how long the regular expression engine will attempt to resolve a regular expression before it times out.
  • Zip compression improvements to reduce the size of a compressed file.
  • Better performance when retrieving resources.
  • Updates to MEF to better support generics.
  • new Asynchronous methods in I/O classes for Asynchronous File Operations
  • Support for Internationalized Domain Name parsing
  • WPF Ribbon Control
  • WCF HTTPS protocol mapping
  • WCF Asynchronous streaming support
  • WCF Contract-first development  as well as ?singleWSDL for service URLs

Test your apps and PLEASE tell us if you have trouble. This is a beta and there is a still time to fix things.

Please don’t hesitate to post a comment on team blogs, or at one of the forums that are actively monitored: Connect (report bugs), UserVoice (request features) and MSDN Forums (ask for help). I know that folks have issues with Connect sometimes, but folks are actively monitoring all these places and are trying to get back to you with clear answers.

ASP.NET Core Framework

Here's a detailed release notes document about what's new in ASP.NET 4.5 and Visual Studio "Web Developer" 11 Beta. The core ASP.NET framework has a lot of new support around asynchrony. Asynchrony has been a theme throughout the whole Visual Studio 11 process and ASP.NET is full of improvements around this area.

There's support for the await keyword, and Task-based modules and handlers.

private async Task ScrapeHtmlPage(object caller, EventArgs e) 
{
WebClient wc = new WebClient();
var result = await wc.DownloadStringTaskAsync("http://www.microsoft.com");
// Do something with the result
}

Even IHttpAsyncHandler (a classic, and a difficult thing to get right) has a friend now:

public class MyAsyncHandler : HttpTaskAsyncHandler
{
// ...
// ASP.NET automatically takes care of integrating the Task based override
// with the ASP.NET pipeline.
public override async Task ProcessRequestAsync(HttpContext context)
{
WebClient wc = new WebClient();
var result = await
wc.DownloadStringTaskAsync("http://www.microsoft.com");
// Do something with the result
}
}

There's security improvements with the inclusion of core encoding routines from the popular AntiXssEncoder library, and you can plug in your own.

ASP.NET also has WebSockets support when running on Windows 8:

public async Task MyWebSocket(AspNetWebSocketContext context) 
{
WebSocket socket = context.WebSocket;
while (true)
{
...
}
}

Bundling and Minification is built in and is also pluggable so you can swap out own techniques for your own, or your favorite open source alternative.

There's lots of performance improvements including features for dense workloads that can get up to a 35% reduction in startup time and memory footprint with .NET 4.5 and Windows 8.

ASP.NET 4.5 also supports multi-core JIT compilation for faster startup and more support for tuning the GC for your server's specific needs.

ASP.NET Web Forms

There's lots of refinements and improvements in Web Forms. Some favorites are strongly-typed data controls. I blogged about this before in my Elegant Web Forms post. There's two way data-binding in controls like the FormView now instead of using Eval() and you'll also get intellisense in things like Repeaters with strongly typed modelTypes.

Web Forms also gets Model Binding (all part of the One ASP.NET strategy) which is familiar to ASP.NET MVC users. Note the GetCategories call below that will bind to a View with IQueryable.

public partial class Categories : System.Web.UI.Page
{
    private readonly DemoWhateverDataContext _db = new DemoWhateverDataContext();
 
    public void Page_Load()
    {
        if (!IsPostBack)
        {
            // Set default sort expression
            categoriesGrid.Sort("Name", SortDirection.Ascending);
        }
    }
 
    public IQueryable<Category> GetCategories()
    {
        return _db.Categories;
    }
}

In this example, rather than digging around in the Request.QueryString, we get our keyword parameter this way:

public IQueryable<Product>GetProducts([QueryString]string keyword) 
{
IQueryable<Product> query = _db.Products;
if (!String.IsNullOrWhiteSpace(keyword))
{
query = query.Where(p => p.ProductName.Contains(keyword));
}
return query;
}

Web Forms also get unobtrusive validation, HTML 5 updates and elements, and those of you who like jQuery but also like Web Forms Controls (as well as Ajax Control Toolkit fans) will be thrilled to check out the JuiceUI project. It's an open-source collection of ASP.NET Web Forms components that makes jQuery UI available in a familiar way for Web Forms people.

ASP.NET MVC and Web API

Last week I blogged about Making JSON Web APIs with ASP.NET MVC 4 Beta and ASP.NET Web API. ASP.NET MVC 4 includes these new features (and a few more) and is included in Visual Studio 11 Beta.

  • ASP.NET Web API
  • Refreshed and modernized default project templates
  • New mobile project template
  • Many new features to support mobile apps
  • Recipes to customize code generation
  • Enhanced support for asynchronous methods
  • Read the full feature list in the release notes

Matt Milner has a great post on where ASP.NET Web API and WCF proper meet and diverge, and why you'd use one over the other. I'll be doing a more detailed post on this also, but I like Matt's quote:

WCF remains the framework for building services where you care about transport flexibility. WebAPI is the framework for building services where you care about HTTP.

ASP.NET Web Pages 2

New features include the following:

  • New and updated site templates.
  • Adding server-side and client-side validation using the Validation helper.
  • The ability to register scripts using an assets manager.
  • Enabling logins from Facebook and other sites using OAuth and OpenID.
  • Adding maps using the Mapshelper.
  • Running Web Pages applications side-by-side.
  • Rendering pages for mobile devices.

There's lots  more to talk about in Razor and Web Pages 2 that I will talk about when Web Matrix 2 comes out.

Visual Studio - for Web Developers

Lot of new Web Features - Hello Opera users!There's an extensive list of features and fixes on the Web Developer Tools team Blog. Here are my favorites.

The HTML Editor is smart about HTML5 and you can develop smart HTML5 sites with any ASP.NET technique.

The CSS Editor has a new formatter, color picker, better indentation, smart snippets and vendor-specific IntelliSense. That's Webkit and Opera in the screenshot over there.

The Javascript Editor has IE10's Javascript engine and supports Javascript as a 1st class citizen with all the support you get in other languages like Go To Definition, brace matching, and more.

Page Inspector is all new and lets you to see what elements in the source files (including server-side code) have produced the HTML markup that is rendered to the browser. IIS Express is now the default web application host.

All the Links

General Info

Download

Secondary Downloads (for the IT folks)

Got Visual Studio issues? Complain (kindly) and vote up features and concerns at their UserVoice site.

Got ASP.NET issues? Complain to me (kindly) and vote up features and concerns at our UserVoice site or ask questions in the ASP.NET forums. There will also be new videos, tutorials and information at http://asp.net/vnext and we are continuing to update the site with fresh content.

Hope you enjoy the Beta. Please do take a moment to install it, try it out, and offer feedback. There is time for us to make changes, fixes and improvements but only if you give feedback.


Sponsor: My thanks to DevExpress for sponsoring this week's feed. There is no better time to discover DevExpress. Visual Studio 11 beta is here and DevExpress tools are ready! Experience next generation tools, today.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.