Scott Hanselman

Download Visual Studio 2013 while your feedback still matters

July 30, '13 Comments [91] Posted in ASP.NET
Sponsored By

That's a lovely scrollbar!

Lots of stuff is happening at MSFT right now. Windows 8.1 is around the corner (did you download the 8.1 Preview?) and development is still happening on Visual Studio 2013.

UPDATE: Don't like the Light Theme? The old VS2010 Blue Theme is back, use it instead. Use whatever Theme relaxes you and whatever text colors make you happy.

Change your theme

Use whatever colors make you happy. Here's 2013 with the 2010 theme.

vs2010

Anyway, the ASP.NET and Web Tools team is hard at work on VS 2013 with Web Tools. Remember that the tooling for ASP.NET was pulled out of VS in 2012 and remains an "out of band release." This gives us more flexibility than we had before and will let us get more time to put features in and fix bugs than some groups.

Truth is, the next 4-6 weeks is when we need to be fixing bugs and finding any edge cases or weird stuff. For example, we know that Glimpse doesn't work well with Web Forms and FriendlyUrls. We are actively working on that now.

Download Visual Studio 2013 (and ASP.NET with Web Tools) while your feedback still matters.

What we need from you is bugs and feedback. You can put suff on:

Should you install VS2013?

I have it installed on all my four machines and nothing has broken yet.

Since Visual Studio 2013 installs side-by-side with VS2012 and VS2010, if you already have .NET 4.5 and VS2012 it's not that risky to install VS2013. This has a Go-Live license and includes .NET 4.5.1.

RISK: If you have only VS2010 and .NET 4.0, .NET Framework will upgrade your .NET 4.0 to 4.5.1. If you are shipping to a server with .NET 4 you'll likely be OK, but you ARE taking a risk, so don't use a work machine you deeply care about to test on if you also have to ship .NET 4.0 only code.

BENEFIT: That said, anything that breaks under 4.5.1 we DO want to know about. Meaning, if ASP.NET 4.5.1 breaks your ASP.NET 4 app we need to know and we will only find out if you test. But, don't use the only machine you have to work on every day if it's all you have to ship with.

We would REALLY appreciate folks testing ASP.NET 4.0 apps to run them up ASP.NET 4.5.1 and find bugs. It's that scenario that is the most interesting.

What do you need to get?

All this works in the Free Web Express version so you don't need to have a paid copy of Visual Studio to install VS2013.

Useful VS 2013 features

There's lots of new stuff (check the ASP.NET Release notes) but here's just a few highlights:

Edit and Continue for 64 bit applications - In VS2010 and VS2012, the edit and continue option is disabled by default when creating a new web application project. In VS2013 preview, we turned it on by default. You can find this option on the Web tab in the web project’s properties window.

One ASP.NET with Updated Templates - You'll see this in my talk at BUILD on What's New in ASP.NET and Visual Studio 2013. The dialog isn't done, but we are moving forward with lots of new improvements. Also, ASP.NET includes Twitter Bootstrap out of the box as the default template.

Extensible Scaffolding Framework with new Web Forms Scaffolds and improved MVC scaffolders. You can now enable an ASP.NET app for MVC or Web API and get all the required packages via NuGet. This moves us towards One ASP.NET. There is no "MVC Project Type" or "Web Forms Project Type." There is just one and you can mix and match as you like.

image

Entity Framework has Async Query and Save support, better POCO support, improved perf, connection resiliency, and Code First mapping to Stored Procedures (and more).

VS tooling enhancements - Editor enhancements, Browser Link. There's an all-new HTML editor that understands HTML5 at the core, lots of stuff there but you'll be most impressed with Browser Link (name will likely change)...it's a bi-directional link between ALL running browsers and Visual Studio, powered by SIgnalR.

3324.clip_image001_thumb_10A440B5

So you can do this:

Updating two browsers and an iPhone from VS2013

New Authentication & Identity Model - Auth and ASP.NET Identity is being fixed and rewritten with extensibility in mind. That includes the existing support for Google, Facebook, Microsoft ID, Twitter, Open Auth in general as well as Windows Auth and Windows Azure Activity Directory. (That last one means you can run an intranet app in Azure and authenticate it against your company's existing Active Directory! That means cloud-hosted intranet apps.)

aspnetauth

New Web API and SignalR functionality - Web API now supports Portable Formatters that can be shared on client and server and you can create clients that work on Windows Phone and Windows Store apps. Web API is also updated to support easier Unit Testing of Controllers. Web API also supports AttributeRouting via an OSS contribution from Tim McCall, and CORS via an OSS contribution from Brock Allen. ASP.NET Web API also supports OWIN and OWIN hosts (it can be hosted outside IIS or in your own Service). SignalR now has iOS and Android support via MonoTouch and MonoDroid in Xamarin tools! SignalR also includes a Portable .NET Client.

We are also (quietly) making other changes moving towards bigger ones, including removing the "Windows-only" Restriction for the ASP.NET Project codenamed "Katana" that will be a big part of the next version of ASP.NET and is a part of the plumbing of this release of ASP.NET as well.

A few of my favorite small Non-ASP.NET specific features are viewing method return values in the debugger (duh!)

Return Values

and "Peek Definition" which lets you look at a method definition without opening the file.

Looking at a method definition without opening the file

Also, the return of "RockScroll" in the scrollbar:

That's a lovely scrollbar!

Consider also getting the newly open source "Web Essentials" - This is our "unofficial Labs" extension where we try crazy stuff. We hope you dig it and even better we hope you help us make it all better.

About Scott

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

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web

If you're not using Glimpse with ASP.NET for debugging and profiling, you're missing out

July 20, '13 Comments [35] Posted in ASP.NET | ASP.NET MVC | Open Source | Tools
Sponsored By
Glimpse NuGet packages

I've blogged about Glimpse since the day I first saw it at Mix 2011's open source fest. It's popular, but frankly, Glimpse is so useful more people need to know about it.

From within your ASP.NET application in Visual Studio, install Glimpse using NuGet. You'll want to install the right Glimpse packages for the ASP.NET features you're using. For example, I'm using MVC4 and Entity Framework 5, so I will use NuGet and:

install-package Glimpse.MVC4
install-package Glimpse.EF5

These packages pull in the core Glimpse libraries plus the hooks for the specific ASP.NET modules and handlers needed for Glimpse to collect all the information about your application and present it to the client side. Be sure to pick the right NuGet packages for your project type.

The releases of Glimpse 1.4.0, and now most recently 1.5.0 improve Glimpse with the addition of a really amazing HUD (Heads Up Display). As you hover over each segment, it pops up with lots of details about the HTTP request, AJAX requests, deep inspection database interactions, and lots more.

Glimpse's new HUD

Here I've hovered over one segment and you can see the time it took to render this first page, and exactly how much time was spent during each activity, from rendering to action methods to database connections.

The Glimpse HUD expanded

You can move from the HUD to the standard Glimpse view. The best part is that each Glimpse Tab is a plugin itself! There's a whole community creating Glimpse Plugins. If you're using RavenDB, or NHibernate, or SignalR or whatever, you can get introspection into what's going on in a Glimpse Tab.

You turn Glimpse on and off with cookies, and you can setup security policy however you want. Glimpse isn't in the background creeping around - you have absolute control over when you want it used. Perhaps local and only when debugging, or perhaps always and with a specific cookie value, it's up to you.

Below you can see the actual SQL query executed by my Entity Framework code and how long it took to execute. I didn't have to change any part of my code or do anything more than just install Glimpse. Glimpse added the modules and handlers, and Glimpse policies can be installed to turn Glimpse on or off based on any option I can think of. I can even put Glimpse into production and only turn it on for certain requests, giving me a profiling tool I can peek at whenever I like.

EF SQL queries viewed within Glimpse

You likely use F12 developer tools in Chrome, IE and Firefox, and you've seen Timeline views before. But remember that Glimpse is JavaScript and HTML on the client - it's NOT a browser plugin - and it's a series of plugins on the server that give you a holistic view that's way more than just what's visible on the client.

Glimpse's Timeline View shows you exactly what's happening on the server, how long it's taking, and how it all fits together.

image

Sessions within Glimpse are all tracked and be optionally named. Since the server is collecting what's going on, you can pull out a popup browser window of Glimpse and connect to sessions from other browsers. Below I'm using an iPhone mobile emulator from ElectricPlum and inspecting requests from another browser window.

Using Glimpse to debug remotely against an iPhone Emulator

Glimpse is all open source and under the Apache 2.0 license. You can certainly help out, but the most interesting thing in my opinion is writing Glimpse Tabs - extending Glimpse to collect and show new data. Tabs can show technical stuff, but even business stuff that's specific to your application or style of application. For example, the Umbraco CMS could make a Glimpse Tab that puts configuration or technical Umbraco specific details up front. A line of business app could show tax details or shopping cart contents.

Glimpse is so useful that it's the first thing I install after I File | New Project on any non-trivial thing I'm working on. It's replaced Mini-Profiler as my go-to "production profiler" for web apps, and if you use ELMAH to collect and manage your application errors, there's even a Glimpse ELMAH plugin!

Check it out and go talk to Anthony and Nik about Glimpse on Twitter and thank for their work!

DISCLOSURE NOTE: The Red Gate company sponsors the Glimpse open source project. Red Gate also sponsored my blog feed this week. That is a cool coincidence, but it's just a coincidence. Red Gate does a lot of stuff. This post about Glimpse was written earlier. Just an FYI for y'all.


Sponsor: Big thanks to the folks at Red Gate for sponsoring the feed this week. Take a moment and check out their free download of Deployment Manager! Easy release management: Deploy your .NET apps, services and SQL Server databases in a single, repeatable process with Red Gate’s Deployment Manager. There’s a free Starter edition, so get started now!

About Scott

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

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web

Redirecting ASP.NET Legacy URLs to Extensionless with the IIS Rewrite Module

May 10, '13 Comments [19] Posted in ASP.NET | IIS
Sponsored By

ASP.NET has included support for "friendly URLs" for a while now. ASP.NET MVC has always supported friendly URLs and more recently, so has Web Forms. That means if you don't want to have the .aspx extension, you certainly don't have to.

However, there's a LOT of existing legacy apps out there as well as apps that you may not have full control over. For example, there's a site that I want to influence but it's got dozens (hundreds) of links to foo.html and bar.html existing pages.

Legacy (n): A super-fancy way of saying "already exists."

What I want to do is kind of sloppy and I'm doing it for aesthetic reasons. I'll hopefully get around to updating the site's links later and know that future links will be extensionless. But look at me, I'm justifying why I'm doing this, Dear Reader. You of all people know that sometimes you just gotta do something just because ya gotta Get It Done™©.

I want to:

  • redirect existing GETs to a /foo.html to /foo
    • Redirects are external
  • but, keep rewriting /foo to the underlying /foo.html so it handles the request
    • Rewrites are internal

I can do all this within my web.config using the IIS Url Rewrite Module.  I can do this with ANY file type that IIS can handle, meaning this isn't an ASP.NET-specific thing. This all happens well before your application gets involved. You'll note I did a similar thing with a PHP app running under IIS just last month.

Here's what my web.config looks like. Note that since I have Azure (or in just IIS 7+ and the Rewrite module) I just added this file. There was no configuration needed. The same would apply to any existing site. Be aware that sometimes super-"greedy" rewrite or redirect rules can end up grabbing ahold of your CSS or JS so you'll want to be aware if something odd happens.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="extensionless" stopProcessing="true">
<match url="(.*)\.html$" />
<action type="Redirect" url="{R:1}" redirectType="Permanent" />
</rule>
<rule name="removeextension" enabled="true">
<match url=".*" negate="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{URL}" pattern="(.*)\.(.*)" negate="true" />
</conditions>
<action type="Rewrite" url="{R:0}.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>

This stuff is hard to write, though.

SIDE NOTE: My RegEx expert Ruslan points out that the final Action could be simplified slightly like this:

<add input="{URL}" pattern="\." negate="true" />

This stuff is also hard to test. The IIS Rewrite module has a great UI for IIS that will write a lot of these rules for you and let you test them interactively:

URL Rewrite module in IIS

Hope this helps. I wrote this post (and bookmarked it) for myself because I am always googling around for this particular rule to remind myself. Now I'll search my own blog. ;) Reason #64 to blog, friends.


SPONSOR: Big thanks to the feed sponsor this past week, Ext.NET (seriously, check out their demos, really amazing stuff!) - Quickly build modern WebForm and MVC (including RAZOR) Apps for ASP.NET. Free pancake breakfast with all purchases!

About Scott

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

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web

One ASP.NET: Nancy.Templates for Visual Studio

May 6, '13 Comments [31] Posted in ASP.NET | Open Source
Sponsored By
NancyFX inside Visual Studio

I hope you've updated to Visual Studio 2012.2 and picked up Web Essentials because we're continuing to add goodness all the time. As we march forward with the One ASP.NET vision, so does the community. One of the major goals has been to make it easier for the community to not only make templates but also live alongside ASP.NET templates as peers. This has been historically hard. It's still too complex, in fact, but it's easier than before. I'm hoping that one day soon making templates will be as easy as making and sharing NuGet packages.

Not only is most of ASP.NET open source, but so are the Azure SDKs, NuGet and more. However, there's a large and rich world of open source frameworks and projects that some companies never get to use either because their company isn't into Open Source or because they won't use code that doesn't come from Microsoft.

Additionally, Microsoft, IMHO, has done a poor job (as a collective) letting developers know that there are options and options are good. Personally, I don't care if you use Entity Framework, or Web Forms, or MVC or Web API. You can use NHibernate, Nancy, Simple.Web, ServiceStack and OpenRasta. It makes no difference to me or my organization. If you are happy and using .NET, then I'm happy and that's great. Microsoft want you to use Azure and Windows, I'm sure, but after that ultimately the rest is just the details of your stack. You should explore the options available and work within your organization to be successful.

On the topic of options, NancyFx is an open source web framework for .NET that uses the Ruby Framework "Sinatra" as its inspiration. (Get it? Frank Sinatra's daughter is Nancy Sinatra.)

A few days ago (with some gentle prodding, and some great team effort) the NancyFx team created a VSIX to integrate the NancyFx Web Framework into the Visual Studio project dialog. (You can also get NancyFx from NuGet, of course.)

It's totally simple from your point of view, as it should be. Download the VSIX, and double click on it. Done.

Installing NancyFX into Visual Studio

Now, in Visual Studio, just File | New Project and  you've got more choices!

NancyFX in the Visual Studio File New Project Dialog

Nancy is a very lightweight and flexible framework for web sites and services. You don't even need ASP.NET proper. You can self-host in your own services or exe, or host within ASP.NET. You can use Razor syntax or choose other View Engines.

Here's Hello World:

public class SampleModule : Nancy.NancyModule
{
public SampleModule()
{
Get["/"] = _ => "Hello World!";
}
}

Interesting and very concise convention, eh? The Get["/"] syntax is a route, saying that an HTTP GET for / should be handled by this => anonymous method. It's all C#, mind you!

Here's the next step, passing a model into a View:

 public class SampleModule : NancyModule
{
public SampleModule()
{
Get["/"] = parameters => {
var person = new Person {
Id = 1,
Name = "Scott Hanselman",
Content = "Lorem ipsum...",
Tags = {"c#", "aspnet", "oss", "nancy"}
;

return View["Index", person];
};
}
}

Nice, eh? Very familiar if you're comfortable with ASP.NET MVC and general MVC-style frameworks. 

If you want to return Json, you can take an object and call AsJson() like this:

Get["/person"] = parameters =>
{
var person = new
{
Id = 1,
Name = "Scott Hanselman",
Content = "Lorem ipsum..."
};
return Response.AsJson(person);
};

UPDATE: I am reminded by commenters that Nancy now supports Content Negotiation ("conneg") and will automatically return the format that the client requested. This means if your HTTP headers say "accept: application/json" then you'll get JSON back automatically. Lovely, and no need for the AsJson() (unless that's what you wanted).

There's samples you can see at http://samples.nancyfx.org and you are encouraged to add your own sample. Just File | New Project, and make a Nancy Demo Application and follow the instructions.

NancyFx has a great community of users and you'll  often find them chatting on Jabbr or in their Google Group. There's even a Resharper Plugin for Nancy. Nancy also runs nicely on Mac with Mono and MonoDevelop.

Kudos and congrats to the Nancy team for being awesome, and for making these templates.

Related Links


SPONSOR: Big thanks to the feed sponsor this week, Ext.NET (seriously, check out their demos, really amazing stuff!) - Quickly build modern WebForm and MVC (including RAZOR) Apps for ASP.NET. Free pancake breakfast with all purchases!

About Scott

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

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web

Penny Pinching in the Cloud: Enabling New Relic Performance Monitoring on Windows Azure Websites

May 2, '13 Comments [12] Posted in ASP.NET | Azure
Sponsored By
New Relic view of my Website

I've been looking for ways to save money running my (now 12) websites in the cloud lately. Getting insights from logs has been helpful, but I really want more details as to what my app is doing so that I might do less of it. Remember the secret of scaling an application.

Have your app do as little as possible. If you do nothing, you can scale infinitely.

I like to use tools like Glimpse to profile my apps, check database calls, and explore what's really going on. If you like application insights you may be familiar with New Relic. They are a clever system that profiles apps of all kinds, including sites ASP.NET and Azure.

I tweeted this afternoon for folks to hit my site and help me test New Relic. My lovely friends on Twitter promptly DDOS'ed my site and I respect them all the more for it.

You can actually see my site getting loaded up in this chart, and see when I scaled up within Azure and switched from Shared to Reserved. The orange instance is shared, and the blue is a NEW instances when I switched to a Reserved VM. At this point, I had enough power to weather the storm. Thanks Twitter!My site getting beaten on

How did I setup New Relic on my Web Site? New Relic happens to have an office in Portland (where I live) so I went to visit today. Coincidentally (true story) their support for Azure Web Sites has sneaked out from a closed beta to an open one recently, so I decided to hide out and see if I could add New Relic performance and application monitoring to the Hanselminutes.com podcast site.

Adding New Relic to your Azure account

Login to the Azure Portal, click on New, then Store, then New Relic from within the Store.

Adding New Relic to my Azure Portal

Pick the free plan. You can have a free plan forever, they say. It doesn't include some "bells and whistles" and a storage of large amounts of historical data, but is otherwise quite functional. Plus you get a free 14-day trial (no credit card needed) of their Pro stuff.

Screenshot (19)

Create the Add-On. They tell me the Data Center Location for New Relic doesn't matter, as you are just going to get a license key.

NOTE: If you already have a New Relic license key and existing billing relationship the you don't have to use the store or add an add-on. You can use your existing license key. However, I want my billing centralized, so any bill from New Relic will go through my Azure account. It's up to you.

Adding New Relic

Now, from within the Azure dashboard, click the new New Relic node. You can click Manage to automatically move over (and automatically single sign on) to the New Relic system dashboard. Note also the Connection Info button there. We'll need that in a minute.

New Relic within the Azure Dashboard

If you click Manage and head over to the New Relic side you'll get a Welcome Message but you won't actually SEE anything interesting until your app has successfully made its first call to their system. You can check out their .NET docs if you like. They are in flux and not entirely accurate, but they'll get there.

We need to setup our Azure Website with some environment info, then add the New Relic NuGet package.

Staying with the Azure Portal, go to the Web Site you're going to instrument, and click Configuration and setup these Configuration Values. This hooks up the New Relic production profiler to the CLR. You can keep this running all the time, and it's easy to turn off.

Add these name/value pairs:

  • COR_ENABLE_PROFILING - 1
  • COR_PROFILER -{71DA0A04-7777-4EC6-9643-7D28B46A8A41}
  • COR_PROFILER_PATH - C:\Home\site\wwwroot\newrelic\NewRelic.Profiler.dll
  • NEWRELIC_HOME - C:\Home\site\wwwroot\newrelic

Your app settings will look like this in your website config within the Azure Portal:

Azure Website Config with New Relic

Make sure you not only Save your config, but also (at least once) do a complete RESTART for New Relic to get a chance to hook in.

Add New Relic to your Web Site

Install the NewRelicWindowsAzure Nuget package using the NuGet Package Manager Console using this command:

Install-Package NewRelic.Azure.WebSites

The website for Hanselminutes.com is running on ASP.NET Web Pages and was written with WebMatrix so I used the NuGet GUI. You can tell that this package JUST got uploaded at the time of this writing as there's only 11 downloads!

New Relic NuGet Package

Install this package and it'll lay down a few DLLS and your newrelic.config file. Go into the newrelic.config and copy in the license key from Connection Info (remember that? It's in the Azure Portal and pictured above) into the  config file. Also update your Application Name to some useful value as that's going to identify your site in the New Relic dashboard.

Here I am publishing my site up to Azure. Only the NewRelic agent dlls that I just NuGet'ed in to my app are being published (and a random jpg I forgot).

Publishing the New Relic Agent to Azure

Once I deployed the site and hit it, I could see Hanselminutes appear within the New Relic system.

Hanselminutes within NewRelic

Here's some of the data I could access now! I can see an updated graph of where my time is being spent, both server side AND browser side.

Response Time

I can see which pages load fast and which don't, and exactly why.

Screenshot (45)

I can see SQL Queries and how long they took, what connections were opened...

Screenshot (48)

And deep timelines showing not just where my time was spend in my application, but also where it was spent in the .NET Framework AND CLR itself!

Screenshot (50)

And of course, I can see Stack Traces of problems with my code.

Screenshot (53)

This just scratches the surface, really, but I'm stoked I was able to get the free New Relic tier setup on Azure Websites in just about 10 minutes. I found two spots where four SQL calls could possibly be collapsed into one. I also found a common (and dumb, on my part) ArgumentNullException that I'd been missing for weeks.

I'm pretty impressed with their offering. I think the Pro Tier is a little spendy for the small indie developer, but cheap for the pro dev. I'd like to see a $5 or $10 tier for small hobbyist sites but for now, Free is going to serve me very nicely.

Now I'm going to go and instrument my other sites!

Related Links

About Scott

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

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Page 1 of 159 in the ASP.NET category Next Page

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