Life, Surf, Code and everything in between
Recent Weblog Posts
A first look at SignalR
Wednesday @ 5:23 am
Last month I finally had a chance to use SignalR in a live project for the first time, and I've been impressed by what this technology offers to .NET developers. It's easy to use and provides rich real-time two way messaging between client and server applications, as well as the ability to broadcast message to all connected clients. This is technology that offers many opportunities to rethink of what we can build with Web applications.
Publish Individual Files to your Server in Visual Studio 2012.2
May 10, 2013 @ 2:29 am
Visual Studio 2012 Update 2 introduces a little known new Web Publish feature that allows publishing individual files to the server. While not a high frequency usage case, it's handy for content files or when you just published a large project and realized you forgot to include a file in the project to publish.
A WebAPI Basic Authentication MessageHandler
April 30, 2013 @ 3:29 am
In my last post I showed how to create a basic authentication filter for custom authentication within your applications. This time I repeat the excercise with a MessageHandler to demonstrate the differences between the two approaches.
A WebAPI Basic Authentication Authorization Filter
April 18, 2013 @ 11:35 am
Recently I needed to implement user based security in a Web API application that's easily accessible from a variety of clients. The customer asked specifically for Basic Auth support and so needed to implement custom Basic Auth support. In this post I describe a simple AuthorizationFilter based implementation of Basic Authentication for Web API.
WebAPI: Getting Headers, QueryString and Cookie Values
April 15, 2013 @ 3:48 am
Finally got tired to trying to remember how to get at the Headers, Cookies and QueryString 'collections' in Web API, since there's zero consistency and messy nested collections to deal with. Here's are a set of extension methods that make it easier.
UNC Drive Mapping Failures: Network name cannot be found
April 04, 2013 @ 11:58 pm
Ran into a nasty issue yesterday trying to map a remote drive via UNC pathing. Basically I was unable to connect with failures occurring instantly and without prompting for credentials even when asking to use different credentials. Turns out the problem is the Network Provider Order - here's more info.
A small, intra-app Object to String Serializer
April 01, 2013 @ 2:41 am
On a few occasions I've needed a very compact serializer for small and simple, flat object serialization, typically for storage in Cookies or a FormsAuthentication ticket in ASP.NET. XML and JSON serialization are too verbose for those scenarios so a simple property serializer that strings together the values was needed. Originally I did this by hand, but here is a class that automates the process.
Experimenting with Online Backups
March 27, 2013 @ 2:07 pm
I recently spent a bit of time looking at online synching/backup software to provide a little more resilience to my backup situation. Lots of choices but nothing that's really quite perfect yet. Here's what I found.
Firing an Entity Framework Database Initializer from within DbContext
March 26, 2013 @ 12:53 pm
Database initializers in Entity Framework can be a pain, especially when you're using EF as part of smaller components that may or may not load into a database shared with other EF Contexts. Here's a small helper utility that lets you internalize the database initializer and fire it the first time the context is loaded.
Text Editor Associations/Extensions in Visual Studio getting lost
March 22, 2013 @ 6:47 pm
Visual Studio allows you to create text editor extensions that map standard Visual Studio editors to custom extensions. It's a useful feature that I use a lot with some older products, but unfortunately I've seen alot of cases where the editor/extension mapping gets lost even though Visual Studio still shows it as registered. Here's more info on the problem and how to fix it at least temporarily.
Using plUpload to upload Files with ASP.NET
March 12, 2013 @ 3:42 am
plUpload is a popular client side multi-file upload component. In this article I describe a small library that abstracts the server side processing of uploaded files with an HTTP handler demonstrate putting it all together with a small Image Upload sample application.
Sql Connection Strings in .Config Files vs. Source Control
February 27, 2013 @ 12:18 pm
Connection strings in projects under source control can be problematic. Each Source Control user can potentially have different connection settings to use a database connection and these differences can't be easily reconciled via Source Control. Here are a couple of approaches that have worked for me to deal with this issue.
Visual Studio Web Publish Lockup? Check for invisible Window
February 21, 2013 @ 12:25 am
If your Web Publish dialog appears to lock up Visual Studio when you click on the Publish option, most likely the Web Publish window is hidden on a second screen that is not currently visible. Here's how you can work around this annoying little bug.
Building a better .NET Application Configuration Class - revisited
December 28, 2012 @ 4:41 am
Managing configuration settings is an important part of successful applications. It should be easy to ensure that you can easily access and modify configuration values within your applications. If it's not - well things don't get parameterized as much as they should. In this post I discuss a custom Application Configuration class that makes it super easy to create reusable configuration objects in your applications using a code-first approach and the ability to persist configuration information into various types of configuration stores.
Process.Start() and ShellExecute() fails with URLs on Windows 8
December 12, 2012 @ 8:14 pm
It appears that on Windows 8 there's a bug in the ShellExecute() API that causes failure in URL navigation when running under Administrative privileges.
A Small Utility to Delete Files recursively by Date
November 30, 2012 @ 9:13 pm
After again searching for a script or tool that can easily delete files recursively down a folder hierarchy with a date filter and coming up with several 'almost there' solutions I sat down and created a small Console app that handles this task. I've posted the resulting project on Github, with both the binary and source code, in case you ever find yourself with the same need.
Set-Cookie Headers getting stripped in ASP.NET HttpHandlers
November 29, 2012 @ 5:38 pm
Ran into a nasty problem with Cookies not getting sent in HttpHandler code when using Response.AppendHandler() with the Set-Cookie key. It turns out it's a very narrow edge case, but one that can bite in unexpected system level applications.
WCF WS-Security and WSE Nonce Authentication
November 24, 2012 @ 5:31 am
I ran into a Web Service last week that required WS-Security headers with an embedded nonce value. Unfortunately WCF doesn't support this particular protocol directly. Here's how to create custom credentials and a tokenizer to write out the customized WS-Security header.
Windows 8 Live Accounts and the actual Windows Account
November 19, 2012 @ 8:10 pm
When you log on with a Windows Live account in Windows 8, what really happens to your credentials? It's not quite obvious, so here are a few thoughts and examples that demonstrate the relationship between Windows and Live accounts.
DevConnections Session Slides, Samples and Links
November 13, 2012 @ 5:20 am
Finally getting around to posting links to my DevConnections session in Vegas a couple of weeks ago. It was a fun time after a long absence from speaking...
HTML5 Input type=date Formatting Issues
November 08, 2012 @ 6:27 pm
The new HTML5 Input types make it easier to display special formatted input types like dates and email addresses. Browsers that support them display a nice UI for editing and can validate values. However, support currently is limited and date formatting especially is complex as it involves using an ISO date format that doesn't fall back nicely to non-supporting browsers.
Back to Basics: When does a .NET Assembly Dependency get loaded
November 03, 2012 @ 4:39 pm
Assembly loading in .NET is often a cause of confusion. So many times I've heard how evil it is to add a reference to some big assembly, if it's just a minor feature. But .NET is really smart in assembly loading and by default uses just in time loading of referenced assemblies. In this post I review when assemblies are loaded with a few simple examples that demonstrate the process.
Caveats with the runAllManagedModulesForAllRequests in IIS 7/8
October 25, 2012 @ 11:15 pm
IIS 7 and 8 support using Managed Modules to handle access to all IIS request content which is very powerful. But sometimes you actually want to not handle non-ASP.NET content and it's not very obvious how to minimize access to non-ASP.NET requests in managed modules.
Dynamic Code for type casting Generic Types 'generically' in C#
October 23, 2012 @ 2:06 am
Here's a short entry on how dynamic can be a life saver when you can't cast a type between multiple objects, specifically when the object in question is a generic type without a common base type to cast to.
A tiny Utility to recycle an IIS Application Pool
October 02, 2012 @ 3:29 am
Here's a small console app to recycle an Application Pool which seems to be something I've needed to do repeatedly in the past.
Creating STA COM compatible ASP.NET Applications
September 18, 2012 @ 6:36 pm
When it comes to deploying STA COM components in ASP.NET only WebForms has native support for STA component. Other technologies like MVC, ASMX Web Services and WCF run only in MTA mode. If you need to run your STA COM Components in ASP.NET here is what you need to know and a few tools that help you create STA compatible handlers.
Passing multiple simple POST Values to ASP.NET Web API
September 11, 2012 @ 4:27 am
One feature conspicuously missing from ASP.NET Web API is the inability to map multiple urlencoded POST values to Web API method parameters. In this post I show a custom HttpParameterBinding that provides this highly useful functionality for your Web APIs.
ASP.NET Frameworks and Raw Throughput Performance
September 04, 2012 @ 6:13 pm
I got curious the other day: How do the various ASP.NET framework compare in raw throughput performance? With so many development choices on the ASP.NET stack available today it's interesting to take an informal look at how raw throughput performance compares.
Using JSON.NET for dynamic JSON parsing
August 30, 2012 @ 5:04 am
Parsing JSON dynamically rather than statically serializing into objects is becoming much more common with today's applications consuming many services of varying complexity. Sometimes you don't need to map an entire API, but only need to parse a few items out of a larger JSON response. Using JSON.NET and JObject,JArray,JValue makes it very easy to dynamically parse and read JSON data at runtime and manipulate it in a variety of different ways. Here's how.
.NET 3.5 Installation Problems in Windows 8
August 27, 2012 @ 3:32 pm
I ran into a major headache with getting .NET 3.5 properly on my Windows 8 install - although installed SP1 was missing and wouldn't properly install. Here's what happened, how to check for the version actually installed and how to work around it.
An Introduction to ASP.NET Web API
August 21, 2012 @ 2:41 am
This article is a hands on tour of ASP.NET Web Api. It covers a fair variety of functionality and goes beyond the most basic introductions by digging into some of the mundane details you're likely to run when first starting out with Web API.
Mapping UrlEncoded POST Values in ASP.NET Web API
August 16, 2012 @ 12:42 pm
Surprsingly Web API does not support POST value mapping to multiple simple parameters on a Web API endpoint. While you can map POST values with model binding or the FormDataCollection native parameter mapping in Web API is a missing feature. Here's what you can and can't do with POST values in Web API.
Where does ASP.NET Web API Fit?
August 07, 2012 @ 4:34 pm
With the pending release of ASP.NET Web API we're finally getting a good HTTP Service solution 'in the box ' in ASP.NET. Web API provides many needed and cool features, but it's not always clear whether you should use Web API or some other technology like MVC to handle HTTP service requests. In this post I discuss what Web API is and a few options of where it fits and potentially doesn't fit.
.NET HTML Sanitation for rich HTML Input
July 19, 2012 @ 2:24 am
If you need to sanitize raw HTML for display in Web applications, the job at hand is scary for .NET backends. Unfortunately it seems there aren't a lot of tools available to help in this formidable tasks and the tools that are tend to be inflexible to the point of often being unusable. In this post I show a base implementation of an HTML Sanitizer that can be customized for your own needs.
Basic Spatial Data with SQL Server and Entity Framework 5.0
June 21, 2012 @ 7:10 am
Spatial data has been available for a while in SQL Server, but if you wanted to use it with Entiry Framework you had to jump through some hoops. In this post I show how basic SQL Spatial data works and then how you can utilize the new features in EF 5.0 to directly access spatial data using your CodeFirst models.
Rendering ASP.NET MVC Views to String
May 30, 2012 @ 1:53 am
Creating templated text output that's not tied to the HTTP output stream is a frequent requirement in my applications. Rendering confirmation emails, password resets, validations and notifications all generate text through templates that require string or stream output that doesn't get sent to HTTP. Here are some helpers that make it easy to create string output from MVC Views...
DropDownList and SelectListItem Array Item Updates in MVC
May 16, 2012 @ 9:44 am
Ran into an 'interesting' behavior today with a cached list of SelectListItem in drop downlist where the cached list was getting updated by MVCs model binder.
Passing multiple POST parameters to Web API Controller Methods
May 08, 2012 @ 10:29 pm
Web API allows for RPC style method access, but there are differences from older Microsoft AJAX APIs when it comes to passing multiple parameters. Here's how Web API handles parameters and how you can optionally manage multiple parameters to API Controller methods.
Amazon Product Advertising API SOAP Namespace Changes
May 03, 2012 @ 4:36 am
Amazon recently broke their Product Advertising API by rolling out a new service version at the same URLs of the old service, which resulted in immediate failure of service. It's an easy fix once you know where to look. Here's how.
GZip/Deflate Compression in ASP.NET MVC
April 28, 2012 @ 4:00 am
If you want to create ASP.NET MVC content that uses gzip or deflate compression you need to use some custom code. Here's an action filter that compresses content in your ASP.NET MVC applications.
Internet Explorer and Cookie Domains
April 25, 2012 @ 6:04 am
Got tripped up today by another IE issue: Internet Explorer will not accept Cookies with local domains set for the Cookie Domain and fail silently.
Getting a 'base' Domain from a Domain
April 24, 2012 @ 9:17 pm
I was surprised to see that there wasn't some way in .Net to retrieve the base domain name from a sub-domain. For example, I want www.west-wind.com, and store.west-wind.com to return me just the base url. Easy enough but there are a couple small issues to check for especially when dealing with string based domain names.
ASP.NET MVC Postbacks and HtmlHelper Controls ignoring Model Changes
April 20, 2012 @ 2:19 am
Today I discovered an MVC behavior I hadn't noticed: For HTML helper controls MVC always uses POSTBACK values to display the control value rather than model values when the View is rendering in a POST back. In effect this means that MVC Views can't update the value of controls during a POST back using the standard HTML Helper Controls.
Wishful Thinking: Why can't HTML fix Script Attacks at the Source?
April 14, 2012 @ 5:49 pm
I'm dealing with user HTML input in a Web application today and again I curse over the complexities involved in sanitizing this html. So today I started dreaming about a possible alternative...
Odd MVC 4 Beta Razor Designer Issue
April 14, 2012 @ 12:54 pm
I have an odd designer issue with MVC 4 Razor pages which are causing errors in the environment.
Physical Directories vs. MVC View Paths
April 05, 2012 @ 2:38 pm
Physical directories that map paths that are also mapped by ASP.NET MVC routes can cause some consternation, especially if you're not aware that there's pathing overlap between the two. This post is a story about an operator error episode of an accidental file move that took a while to trace down due physical path interference.
Creating a JSONP Formatter for ASP.NET Web API
April 02, 2012 @ 5:03 pm
Web API doesn't include native JSONP support, but it's pretty easy to create a custom formatter that handles this task. Here's how to create a JsonpFormatter and hook it up as well as a short review of how JSONP works.
ASP.NET Web API and Simple Value Parameters from POSTed data
March 21, 2012 @ 5:05 pm
There are a few odd behaviors with Web API and its handling of simple parameters to Controller methods. While complex values serialize just fine, simple values like strings and dates and form variables require special attention.
Dynamic JSON Parsing in .NET with JsonValue
March 19, 2012 @ 3:09 am
The JsonValue/JsonObject/JsonArray classes in the System.Json are new for the full .NET framework and recently introduced with the various betas of ASP.NET (and previously WCF) Web API. JsonValue fills the need for dynamically parsing and serializing of JSON at runtime.
.NET 4.5 is an in-place replacement for .NET 4.0
March 13, 2012 @ 11:43 am
With the betas for .NET 4.5 and Visual Studio 11 and Windows 8 shipping many people will be installing .NET 4.5 and hacking away on it. There are a number of great enhancements that are fairly transparent, bBut it's important to understand what .NET 4.5 actually is in terms of the CLR running on your machine. When .NET 4.5 is installed it effectively replaces .NET 4.0 on the machine. .NET 4.0...
Using an alternate JSON Serializer in ASP.NET Web API
March 09, 2012 @ 3:30 am
The default serializer in ASP.NET Web API (at least in Beta) is the DataContractJsonSerializer with all of its warts and inability to not serializer non-typed objects. In this post I'll talk about the issues and how to plug-in alternate JSON parsers to handle more complete JSON serialization in Web API.
Removing the XML Formatter from ASP.NET Web API Applications
March 09, 2012 @ 1:51 am
When viewing ASP.NET Web API output in browsers the content is usually displayed as XML which is not my preferred choice. Even though JSON is Web APIs default format XML continues to be displayed. Here's some discussion on why this happens and how you can work around it.
Using the HTML5 <input type="file" multiple="multiple"> Tag in ASP.NET
March 06, 2012 @ 1:54 am
HTML5 allows for multiple files to be uploaded from a single file input control. Here's how you can use it and capture files in ASP.NET.
SnagIt Live Writer Plug-in updated
March 03, 2012 @ 5:07 pm
I've updated my SnagIt plug-in for Windows Live Writer to work with SnagIt 11. Also updated the user interface slightly and moved the source code to GitHub.
Make your CHM Help Files show HTML5 and CSS3 content
February 15, 2012 @ 2:17 pm
Want to get your CHM files to display content in HTML5 and CSS rather than the stock IE7 quirks more rendering used by default? This blog post describes how you can take advantage of newer HTML and CSS specs in your CHM files.
Creating a dynamic, extensible C# Expando Object
February 08, 2012 @ 2:28 am
In this post I discuss a custom extensible dynamic type implementation that allows you to extend existing types with dynamic properties at runtime.
Dynamic Types and DynamicObject References in C#
February 01, 2012 @ 2:47 am
This post explains the difference between dynamic reference and explicit references of an IDynamicObject implementation and how they behave differently.
Unable to cast transparent proxy to type <type>
January 13, 2012 @ 1:25 pm
If you've ever run into the Unable to cast Transparent Proxy to
error, you know how frustrating it can be. Usually this is caused by multiple assemblies causing unexpected load behaviors. Here's what the problem is and how you can check for problems.
Problems with opening CHM Help files from Network or Internet
January 11, 2012 @ 12:13 am
Opening CHM files from a non-local location is no longer supported. Conveniently there's no decent error information displayed for this error so your first thought goes that there's something wrong with your help file. Here's an overview of the issue and some solutions on how to deal with it.
IE9 not rendering box-shadow Elements inside of Table Cells
January 03, 2012 @ 6:44 pm
Looks like IE9 has a bug that won't render box-shadow CSS when the box-shadow is contained within a table that has border-collapse set. Here's what the problem is and how to work around it.
XmlWriter and lower ASCII characters
January 02, 2012 @ 2:36 am
If you've ever tried to generate an XML document from content that contains lower ASCII characters you might have found out that this will throw exceptions. Here's why this happens and how you can work around the issue in a pinch.
Changing the default HTML Templates to HTML5 in Visual Studio
December 23, 2011 @ 4:19 am
The default WebForms templates in Visual Studio still use the XHTML doctype headers by default. HTML5 doctype headers are easier to use and read and with HTML5 support now becoming mainstream and backward compatible with older browsers its time to switch those doctype headers. This post demonstrates how to change the default VS templates or create new templates altogether. With HTML becoming more prominent and the new headers being easier to read and smaller in size, it's
Debugging Application_Start and Module Initialization with IIS and Visual Studio
December 15, 2011 @ 2:19 am
If you're running the full version of IIS and you try to debug your Web application's startup code in Application_Start you might have found that you can't debug this code as the debugger doesn't break there. Here's why and some easy ways you can work around this limitation.
HTML 5 Input Types - How useful is this really going to be?
December 10, 2011 @ 9:13 pm
The HTML 5 input controls enhancements seem like a nice feature - until you look a little closer and realize that that validation and styling these control enhancement use are likely going to interfere with your existing application logic and styling. Here are are some thoughts on the subject.
HTML 5 Input Types on WebForms Controls
December 10, 2011 @ 8:24 pm
HTML5 input types are new, and as it turns out ASP.NET Webforms input controls can easily create HTML5 input elements.
A Key Code Checker for DOM Keyboard Events
December 08, 2011 @ 3:47 am
Creating a Dynamic DataReader for easier Property Access
December 06, 2011 @ 5:04 am
Custom dynamic types in .NET are great to wrap other data structures into easier to use and cleaner object.property interfaces. In this post I demonstrate how you can create a dynamic DataReader that allows access to a DataReader's fields using plain object.property syntax.
jQuery Time Entry with Time Navigation Keys
November 30, 2011 @ 2:23 am
How do you display editable time values in Web applications? While date display has a pretty clear UI choice with date pickers, visual time picking isn't very efficient. In this post I show a keyboard based alternative to navigating and entering time (and date values) values using hotkeys hooked up through a jQuery plugin.
Creating a Dynamic DataRow for easier DataRow Syntax
November 24, 2011 @ 3:13 am
The Dynamic Language Runtime features in .NET 4.0 make it very easy to create custom dynamic types that use alternate 'data sources' to expose a new member interface. In this post I describe a simple example that exposes a classic DataRow as a dynamic type to allow cleaner syntax and no need for type casting when accessing DataRow objects.
Dynamically creating a Generic Type at Runtime
November 11, 2011 @ 4:39 am
How do you get a type reference to a generic type instance for a specific set of generic type parameters at runtime? Generics is primarily a coding time tool that creates code at compile time. It's not real easy to create generic types at runtime using dynamic type information. In this post I talk about an issue I ran into while trying to create dictionary types on the fly.
Using the West Wind Web Toolkit to set up AJAX and REST Services
November 03, 2011 @ 4:55 am
SnagIt Live Writer Plug-in Updated
October 13, 2011 @ 2:57 pm
I've updated my Live Writer SnagIt plugIn that provides screen captures to LiveWriter if you have TechSmith's SnagIt installed for professional looking screenshots directly from SnagIt into your Live Writer posts.
Loading jQuery Consistently in a .NET Web App
October 10, 2011 @ 12:56 pm
Loading jQuery into a page consistently across the lifetime of an application involves, managing versions and updating urls frequently. In this post I look at my preferred way to load jQuery and how to manage the script reference that gets embedded into the page with a single update location.
An easy way to create Side by Side registrationless COM Manifests with Visual Studio
October 09, 2011 @ 3:58 am
Registrationless COM makes it possible to run COM components without registry configuration making for an xCopy deployable solution. The process is not terribly difficult but not easy to debug if something goes wrong. Here's how you can use registrationless COM in your apps.
Getting a Web Resource Url in non WebForms Applications
October 05, 2011 @ 3:29 am
Need to retrieve Web Resource Urls from a .NET assembly, but not running in WebForms? Here's how you can create a small helper function that lets you retrieve WebResourceUrls from Razor or MVC applications.
May, 2013 (2)
April, 2013 (5)
March, 2013 (4)
February, 2013 (2)
December, 2012 (2)
November, 2012 (7)
October, 2012 (3)
September, 2012 (3)
August, 2012 (5)
July, 2012 (1)
June, 2012 (1)
May, 2012 (4)
April, 2012 (8)
March, 2012 (7)
February, 2012 (3)
January, 2012 (4)
December, 2011 (6)
November, 2011 (4)
October, 2011 (4)
September, 2011 (3)
August, 2011 (2)
July, 2011 (3)
June, 2011 (1)
May, 2011 (4)
Visual Studio (51)
Web Services (17)
Web Api (15)
Microsoft AJAX (13)
Web Connection (8)
Sql Server (8)
West Wind Ajax Toolkit (7)
Html Help Builder (5)
Live Writer (4)
Software Development (4)
Source Control (4)
Visual Studio (3)
Help Builder (3)
Entity Framework (3)
Web Design (2)
Internet Explorer (2)
Dynamic Types (1)
Control Development (1)
Web Deployment Projects (1)
© Rick Strahl, West Wind Technologies, 2005 - 2013