Closing and Re-opening tabs in Visual Studio with Ctrl+W

Visual Studio 2017 Undo-Close Update: The Productivity Power Tools have spun off into a bunch of more-focused extensions. To get Undo Close in Visual Studio 2017, you will want the Power Commands extension now. Visual Studio 2013 Undo-Close Update: Since the prior options for re-opening closed tabs fell apart with the release of Visual Studio 2013, you will need the newly released Productivity Power Tools 2013. Update: now with the ability to re-open closed tabs with Ctrl+Shift+T. This also allows you to re-open tabs closed by a project file reload, which is fantastic! Ever tried to close a tab in Visual Studio 2010/2012 with Ctrl+W. If so, you find yourself selecting the current word in your text editor (Edit.SelectCurrentWord). I don’t use that shortcut, though I could see it being handy over my usual Ctrl+Shift+Right-/Left-Arrow. I do, however, use Ctrl+W to close windows/tabs in just about every other program I use. In order to make that shortcut work for your Visual Studio editing, you just need to assign it to File.Close instead. For the visual, here’s a snapshot similar to what you will want (note: I already made this change before snapping a pic, so yours may look slightly different)…. Continue reading

Initial setup for a new ASP.NET MVC site in IIS7

Background Over the years, I have spent far too many hours running the same set of commands against ASP.NET and ASP.NET MVC sites to bring them up to what I consider a starting point. Most of the time, I have to refresh myself about how to do at least one of them. This is a list of those commands in a central location for myself and anyone else to use. As with any good instructions, there is no guarantee you won’t completely destroy your server, site, or soul using these commands. I can only say they worked for me once. Remove unnecessary HTTP headers Server X-Powered-By X-AspNet-Version X-AspNetMvc-Version Adding dynamic content compression (e.g., GZIP) GZIP for JSON and JSONP content types (e.g., “application/json”) Complete appcmd command-line list Remove unnecessary HTTP headers By default, IIS and ASP.NET give you a few headers in each and every HTTP response sent out. Server: Microsoft-IIS/7.5 (or 7.0, or whatever IIS version you have) X-Powered-By: ASP.NET X-AspNet-Version: 4.0.303319 (or 2.0.50727, or 1.1.4322, or whatever version you have) X-AspNetMvc-Version: 3.0 (or 2.0, or 1.0, or whatever version you have) People will rant and rave about removing these headers for security and whether that helps. I am… Continue reading

From jsFiddle to GitHub to AppHarbor to stackgeography.com

Update I finally put together an app listing on StackApps. If you like stackgeography.com and you have a StackApps account, I’d love for your vote on the StackGeography app page. Background My latest project at my full-time job with Sierra Trading Post is their Mashery-managed API. It currently includes most everything you would expect from a retail API: departments, brands, products, search, and reviews. I would like it to include a few things that are less typical but fun to work with from a data aggregation standpoint. One example: recent order locations. While it may not see a lot of outside use, it would be quite nice for our internal observation; it would go great on the handful of large screens around the company with site statistics continually updating on them. In order to put together a proof-of-concept that I could even do this, I wanted to make a mapping demo using someone else’s API. Since I am responsible for the Sierra Trading Post API, I try to research other APIs to learn from their successes and pain points. One such API that has provided a lot of [positive] learning is the Stack Exchange API. It just so happened that… Continue reading

Adapting Visual Studio code styling differences for open source project contribution

Background Today, while incorporating Lee Dumond’s MVC Route/URL Generation Unit Tester into a project, I found a desire to contribute some code I thought would make the package easier to use. Unfortunately, the project code formatting looks nothing like my preferred conventions (some form of 1TBS, I guess). Until Visual Studio offers a way to distribute code style settings to source control consumers easily, I needed a different option. While preparing demos for a mobile web development talk for the Cheyenne Computer Professionals group, I stumbled on Mike Minutillo’s tip for running a “demo” instance of Visual Studio where I could sandbox my presentation settings optimized for an elderly VGA projector. This sparked an workaround idea for dealing with multiple formatting settings of various projects I may work on. Rather than force my conventions on the project (generally not acceptable) or give up on my own style (generally not acceptable), I decided to try using a “demo” instance of Visual Studio with that projects styling conventions set. Right-click where I want the shortcut. Specify a path to Visual Studio 2010 using the /RootSuffix option. On 64-bit Windows, %programfiles(x86)%\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe” /RootSuffix YourStylingNameHere On 32-bit Windows, %programfiles%\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe”… Continue reading

Getting dynamic ExpandoObject to serialize to JSON as expected

Serializing ExpandoObjects I am currently creating a JSON API for a handful of upcoming Sierra Trading Post projects. When I found myself generating JSON for a stripped-down representation of a number of domain classes, all wrapped with some metadata, I turned to dynamic and things have been going quite well. Unfortunately, there was a hurdle to getting the JSON to look the way I wanted. If you start playing around with serializing ExpandoObject to JSON, you will probably start finding a number of options. The easiest solution to find is the one that comes with .NET, JavaScriptSerializer under System.Web.Script.Serialization. It will happily serialize an ExpandoObject for you, but it probably won’t look the way you expect. Your searches will probably vary, but I found Newtonsoft’s JSON.NET, which handled ExpandoObject right out of the NuGet box. Then I stumbled on ServiceStack.Text (also “NuGettable”). While it does even weirder things than the .NET serializer with ExpandoObjects, it supposedly does them very fast. Test code dynamic test = new ExpandoObject(); test.x = “xvalue”; test.y = DateTime.Now; BCL JavaScriptSerializer (using System.Web.Script.Serialization;) JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer(); string jsonOfTest = javaScriptSerializer.Serialize(test); // [{“Key”:”x”,”Value”:”xvalue”},{“Key”:”y”,”Value”:”\/Date(1314108923000)\/”}] Not quite what I was looking for but it makes sense if… Continue reading