Last 50 Comments

re: Creating ASP.NET MVC Negotiated Content Results
Saturday @ 12:18am | by Rick Strahl

Alan, any code you incorporate from the toolkit must include the license header. Other than that there are no restrictions.
re: Publish Individual Files to your Server in Visual Studio 2012.2
Friday @ 7:56am | by Rob Gaudet

Wow, yes, individual file publish is an awesome feature. As is the ability to publish the project from VS. MS please keep making mundane tasks easier on developers!
re: Passing multiple POST parameters to Web API Controller Methods
Friday @ 2:04am | by Milos

I have problem with these example, where I pass multiple arguments into Controller, I get error "System.MissingMethodException: Cannot create an abstract class."
I use 4.5, Google Chorme browser.
re: JavaScript JSON Date Parsing and real Dates
Thursday @ 10:48am | by Michael

Thanks for this! I had real dates in my client, but after being JSONified and sent to the server, they ended up as strings in the database (mongodb). I added your code to my server and now I have real dates in my database.
re: Prefilling an SMS on Mobile Devices with the sms: Uri Scheme
Thursday @ 7:26am | by Ravi

I am not seeing the pre-filled text if I don't pass the phone number, I don't know the phone number upfront, we want the text to appear and let the user to choose whomever they need to send it to. So far I was not successful.

sms:;body=message is not working as expected on iOS 7.1.1. Any workarounds?

Thanks in advance
re: Rendering ASP.NET MVC Razor Views outside of MVC revisited
Wednesday @ 11:18am | by Jonathan

Hi Rick, Thanks for the code. I noticed if you give an incorrect path to a view, RenderViewToStringInternal at this line:

viewEngineResult = ViewEngines.Engines.FindView(Context, viewPath, null);

Will still return a ViewEngineResult but the View property will be null and throw an exception here:

                var ctx = new ViewContext(Context, view,

So this line is not reached:

            if (viewEngineResult == null)
                throw new FileNotFoundException();

re: West Wind WebSurge - an easy way to Load Test Web Applications
Wednesday @ 7:38am | by Sam Shirley

Is there a way to chain calls together? For example, calling an AddRecord method, taking the resulting Id, and using that Id to call a DeleteRecord?
re: WCF WS-Security and WSE Nonce Authentication
Wednesday @ 6:15am | by Moises

Oh! you saved my life with this post. It explains it so clearly and all the steps together. Thank you very much!
re: WPF Bindings and CurrentCulture Formatting
Wednesday @ 3:02am | by Nige

Thanks for this useful post and thanks Allen for the corrections.

I found that, for example if the Resources.resx file contains English texts, there's no need to have a separate Resources.en.resx file. .NET will automatically fall back to the "main" Resources file if the relevant culture-specific file can't be found.

Additionally it seems that although CultureInfo.CurrentCulture is correctly set to the current system culture, Thread.CurrentThread.CurrentUICulture is not. It's this property that determines which resource DLL will be loaded. So to automatically load the correct resources for the current system culture (which is surely the most common scenario) the code should be:

var cultureName = CultureInfo.CurrentCulture.Name;
   new FrameworkPropertyMetadata(
Thread.CurrentThread.CurrentUICulture = CultureInfo.CurrentCulture;

re: Creating ASP.NET MVC Negotiated Content Results
August 26, 2014 @ 4:53am | by Alan Hemmings

Hi Rick, just seen that this code is also available as part of your westwindToolkit that requires a licence to use. Do we need "said" licence to use the code in this article in a commercial project, e.g. "at work"? ta, Alan
re: Creating ASP.NET MVC Negotiated Content Results
August 26, 2014 @ 4:48am | by Alan Hemmings

Awesome stuff Rick, exactly what I needed as well, thank you for all your effort, super appreciated. If you're ever in the UK, please look us up (camdug developers), I would love to buy you a car, or a beer, to thank you! (one or the other at least ;-D)
re: ASP.NET MVC Postbacks and HtmlHelper Controls ignoring Model Changes
August 24, 2014 @ 12:22pm | by Simon Papworth

Thank you, 24 elapsed hours of a bank holiday weekend up in smoke because of this badly explained behaviour, I found the ModelState being different to the Model shortly before finding your article.

Thank you, save my Bank Holiday Monday.

I hate 5 minute enhancements!
re: The broken Promise of the Mobile Web
August 21, 2014 @ 7:09am | by Harvey

Sounds like opportunity waiting to happen... take the smartphone desktop icon, why not link to a server that stores your profile and state in each of your web apps? It would add one step by popping up a menu of where you want to go today, not a big price to pay and perhaps there would be other advertising or subscription based benefits. And it would fit into the model you talked about where there might be a clearing house for web apps where user feedback would also be public.

re: The broken Promise of the Mobile Web
August 19, 2014 @ 9:56am | by Steve

Umm, please tell us what you really think!

Yep, unfortunately too much of the conflict is involves App $tores and turf wars.

I like your point about Windows Phone -- what do that have to lose by tacking a new tack?

However, most non-developer types don't really think about native vs. hybrid vs. an icon pointing to a 'pure' website. Either the app exists in the app store for the platform they are running or it doesn't exist at all. Pinning URLs or getting shortcuts is too messy. So there would be some re-aligning of the consumer mindset required in addition to cleaning up the technology.

It is amazing, with all the resources of both people and money and corporate know-how, that some of these obstacles still exist.
re: The broken Promise of the Mobile Web
August 18, 2014 @ 4:08pm | by Cory House

Superb post Rick. In a world of fast Javascript engines, rich client-side frameworks, and solid network coverage, the list of justifications for building native apps just keeps getting shorter. The technical challenges are minimal and once one platform dives in with rich support, others will likely feel obligated to follow.

This era reminds me a lot of the Flash craze of the late 90s. Once HTML and browsers grew up, Flash's various downsides started to outweigh its benefits. With ES6, and the evergreen browser movement spurring innovation, I see a bright future for mobile Web Apps.
re: The broken Promise of the Mobile Web
August 18, 2014 @ 1:37pm | by James Monte

Excellent article Rick.. I agree with you on everything.. It's driven by money... For the phone vendors: Native App Store = money for phone vendor.. Web App = no money for phone vendor.. Until they can make money from Web Apps, they will be shooting themselves in the foot if they made it possible to build more robust apps with access to the phones functions...
re: The broken Promise of the Mobile Web
August 18, 2014 @ 1:35pm | by Rick Strahl

@Al - that hits the nail on the head. We can build the necessary UI for building effective mobile applications, but we're stuck because of the lousy device integration.

It wouldn't be difficult for device platform vendors to make Web based applications first class citizens on mobile devices.

But not there yet unfortunately and it's going to be an uphill to overcome the status quo with this not benefiting the mobile platform vendors.

re: The broken Promise of the Mobile Web
August 18, 2014 @ 12:03pm | by Al

Great article... It is a shame I can make a great web based mobile app that can do everything it would do if I had the resources to make it native, however so many people will not ever user it b/c it "isn't in the app store".
re: The broken Promise of the Mobile Web
August 18, 2014 @ 10:08am | by Daniel

Good points, Rick- I also enjoyed your similar discussion on DNR. There is definitely room for improvement in the areas you suggest. I do think mobile web has "arrived" for a whole class of apps - namely enterprise line-of-business apps. In these forms-on-data type apps, you rarely need things like accelerometer or high-end graphics. Plus, you have a captive audience who can generally "deal" with the odd white screen or one-time install process if it means they can do their work from any device.

I've done several with offline and local storage, bootstrap and angularjs or knockout. I am left scratching my head as to why anybody would write an internal application using a native stack like Windows Forms, WPF, or native iOS/Android. I hadn't noticed the white screen issue until you mentioned it here, but none of my users have noticed either ;)

Public-facing apps- sure- discovery and installation are a pain, as are the nuances around advanced sensors, graphics, etc. And you want the UX to be spotless. In one sense, though, thats "just the web". Some desktop websites are hard to find and suck when you get there. Others are easy to find and work well. Frameworks like Bootstrap and Angular are doing a good job to push things forward, but it would help if device OS and browser manufacturers came together a bit more on this.
re: The broken Promise of the Mobile Web
August 18, 2014 @ 9:10am | by Michael

I'm glad you are trying to push mobile web apps forward, but this all seems to be about money. This dream web app world of yours (which devs would love) seems like it would be a nightmare for the stores. What would prevent people from letting users buy access to their apps outside of a store, or buy some token they can use to active your app, when the app is no longer inside of an app store? I really hope we can one day have apps like you describe though.
re: West Wind WebSurge - an easy way to Load Test Web Applications
August 16, 2014 @ 8:39pm | by Bill Tresson

Great little tool. Easy, quick and gets the job done. I ran it on my current Web app and immediately discovered a couple of small performance problems that I was able to pinpoint and fix. Going to be running tests frequently on my sites under development to see issues as they crop up. Thanks for highlighting the need to check performance and creating a tool to make it so easy, Rick...
re: ASP.NET MVC Postbacks and HtmlHelper Controls ignoring Model Changes
August 15, 2014 @ 11:59am | by santosh

Damn, I'm from ASP.NET background slowly transitioning to MVC. I was really caught up with this anomaly(from the perspective of webform developer) until I landed your page. Thanks for this very useful information.
re: Tracing WCF Messages
August 15, 2014 @ 9:01am | by Manjit

Hi Rick, thanks for the article. Saved me incredible amount of time.
re: ASP.NET MVC Postbacks and HtmlHelper Controls ignoring Model Changes
August 14, 2014 @ 2:26pm | by Jason

The real problem for me is Presentation (or re-presentation) of the View. Say for example my user enters their name in the Name field, but decides to put 10 spaces first, or say 5 spaces before First Name and Last Name (assuming 1 field here). Then on validation error and re-presentation of the View, according to the way the Helpers work now, that user would see their name exactly as entered (spaces and all). While this is sure to be a rare instance, it's something I like to "clean-up" on re-presentation (I like that control. It also isn't breaking validation). The other concern is the clearing of a field on validation error, making the user re-enter that data.

This article also makes the argument for updating the View with necessarily corrected information.

I think Microsoft's implementation here should be made more flexible. Thanks Rick, I was struggling with this myself for the past few days. Hard to wrap your head around when coming from other languages such as Java or PHP.
re: Creating ASP.NET MVC Negotiated Content Results
August 14, 2014 @ 11:52am | by adam

Nice work!
Exactly what I needed to extend an existing mvc site to easily extend current controller actionresults to be called for json results.

I'm just looking to use existing ActionResults & Views without having to pass in the view name on each. For example I have a view called "Customers" and thus ideally just change.
public ActionResult Customers()
    return View(repo.GetCustomers());

public ActionResult Customers()
    return new NegotiatedResult(repo.GetCustomers());

Any advice on how to change the NegotiatedResult to retrieve the ViewName so I don't have to pass it in to each?
re: Caveats with the runAllManagedModulesForAllRequests in IIS 7/8
August 14, 2014 @ 6:11am | by William Gross

Thank you so much for this post, Rick! Your post in combination with was the only documentation I could find on the *true* purpose of ExtensionlessUrlHandler, which is to force all extensionless requests to run in managed mode so that they have the opportunity to be routed by MVC or Web API.
re: AngularJs ng-cloak Problems on large Pages
August 13, 2014 @ 11:53pm | by thanhtruongngoc


It works well with style.

re: IIS Default Documents vs. ASP.NET MVC Routes
August 13, 2014 @ 11:28am | by Chris

Thanks so much. Great article, great help, especially after 1.5 hour of looking through junk then finding your article of gold. Thanks! :)
re: Rendering ASP.NET MVC Views to String
August 11, 2014 @ 1:10pm | by Rich

Just what the doctor ordered! Thanks for sharing!
re: West Wind WebSurge - an easy way to Load Test Web Applications
August 09, 2014 @ 9:00am | by Rick Strahl

@Sabry - yes I played with jMeter and didn't like what I saw there. Yes it would work, but not as straightforward as I'd like it to be. BlazeMeter is a cloud based solution so that's what I needed to avoid and also not free for any sort of realistic load scenario.
re: West Wind WebSurge - an easy way to Load Test Web Applications
August 09, 2014 @ 7:12am | by Bruce

Rick, I was glad to heard you on .Net Rocks. WebSurge looks awesome! Looking forward to trying it out on our next project.
re: West Wind WebSurge - an easy way to Load Test Web Applications
August 08, 2014 @ 9:18am | by Sabry Guen


Did you consider using JMeter or BlazeMeter before building your own?
Free and gets the job done :-)
re: Disable User Account Control On Windows 8
August 07, 2014 @ 11:27pm | by Jane

nice atricle. I just wondering if you do it the same way in windows 8 like it mentioned at this site.
re: ASP.NET MVC Postbacks and HtmlHelper Controls ignoring Model Changes
August 07, 2014 @ 6:42am | by Carlos Cysneiros

Life Saver! I spent an entire day...thinking I was crazy...whenever I updated a property in the model on a POST, the new value would not be editable (It would be okay for DisplayTextFor). Thank You
re: IntelliSense for Razor Hosting in non-Web Applications
August 06, 2014 @ 6:22pm | by Rick Strahl

@Iaacov - I think in order for that to work you need to add the LINQ namespace to the page or the web.config. In ASP.NET that happens automatically but not here. I'll add it as a default to the latest version of RazorHosting as it's .NET 4.0 - the old version started with .NET 2 and LINQ support wasn't guaranteed.
re: IntelliSense for Razor Hosting in non-Web Applications
August 06, 2014 @ 5:07pm | by Iaacov

I'm using the first approach (templates included in project) and IntelliSense works great, except for extension methods, e.g. Linq extensions.
Is there a solution?
re: A WebAPI Basic Authentication MessageHandler
August 06, 2014 @ 12:00am | by FH

Just stumpled upon these posts and - thumbs up.

Also took a look at the source and discovered your toolbox.

I grabbed a copy and will have a look at it later but the least I can do shout out loud:

THANKS! (caps intended)

Though through a lot of confusing a finally have made my way through ASP.NET Identity and I have my with it - but you can never get enough of good code samples to feed your codemonkey when he is grumbling over stubborn code.

Have a very good day.

By the way - forgive me - I recently found that can feed your minds hunger for answers to big questions of life.
re: West Wind WebSurge - an easy way to Load Test Web Applications
August 05, 2014 @ 8:51am | by Rick Strahl

@Jamie - Currently you can override Cookies and Authorization for every request. There's no query string or POST parsing at this point, but I could see adding that as an option to provide key value pairs for each that get added or replaced.

I also plan to add a plug-in interface so you can use code to look at every request as it goes into processing and then comes out on the other end so you can modify and capture the code.
re: A WebAPI Basic Authentication Authorization Filter
August 03, 2014 @ 11:51am | by EB

This is great, thanks! The only thing I did different is to implement the IAuthorizationFilter so that I didn't need the MyBasicAuthenticationFilter class. My actual authentication occurs in OnAuthorizeUser().

So, this:
public class BasicAuthenticationFilter : AuthorizationFilterAttribute, IAuthorizationFilter

Instead of:
public class BasicAuthenticationFilter : AuthorizationFilterAttribute

And my attribute looks like this:
public IEnumerable<string> Get() { return new string[] { "value1", "value2" }; }

Thanks again for this post! Great stuff, exactly what I was looking for!!!
re: Using FiddlerCore to capture HTTP Requests with .NET
August 01, 2014 @ 6:18am | by Jamy Ryals

Beware, you need a lawyer to understand the license for FiddlerCore. I have no idea if I'm able to use it or not.
re: Basic Spatial Data with SQL Server and Entity Framework 5.0
August 01, 2014 @ 5:04am | by Martin

Thank you. One of the best articles i read in this year. Keep up the good work.
re: Article: A low-level look at the ASP.NET Architecture
July 31, 2014 @ 4:47pm | by Richard

An excellent article and still highly informative here and now in July 2014. Obviously some of the end bits have changed with new MVC Handlers etc but still I was able to follow along using and much of the core methods still spot on which says something about the stability of the framework I guess.

I will be reading a couple of "top up" articles next on codeproject etc to bring into line with IIS 7.5 -8 but I'm still struggling to find articles of this quality and depth when it comes to how security and identity are handled/injected throughout the request pipeline.

Something similar to this article discussing security from http.sys all the way to NTFS and back would be ideal. Any thoughts?

Thanks again either way. I know these articles take quite a bit of time to mangle together.... specially so waay waay back in '05 I bet.
re: Accepting Raw Request Body Content with ASP.NET Web API
July 31, 2014 @ 1:06pm | by Isaac

Small adjustment to fix issues where the current thread values (Principal, etc.) are being lost before it gets to the controller.

Instead of:

return actionContext.Request.Content
                    .ContinueWith((task) =>
                        var stringResult = task.Result;
                        SetValue(actionContext, stringResult);

Do this:

var rawData = actionContext.Request.Content.ReadAsStringAsync().Result;
SetValue(actionContext, rawData);
return EmptyTask.Start();

re: IIS Default Documents vs. ASP.NET MVC Routes
July 30, 2014 @ 10:20am | by Rick Strahl

@Karl - that's kind of an odd setup. But I think you can do that by creating a custom route or web.config RewriteUrl rule that reroutes any link to another. With configurations and .config transformations rewriteurls can be different on your dev setup and production.
re: IIS Default Documents vs. ASP.NET MVC Routes
July 30, 2014 @ 10:00am | by Karl

That is great!

I like to drop a default.aspx during development, or downtime and then just remove it and it would find the /index.aspx page which would be the normal run-time home page.

So now I can drop the default.aspx in my MVC site and it will show a "under dev" logo or whatever.

The only problem is since there is no index.aspx file on MVC sites I can't navigate to mydomain/index.aspx and see the content that would be displayed e.g. for client previews etc.

Any idea?
re: Using FiddlerCore to capture HTTP Requests with .NET
July 29, 2014 @ 10:20am | by Rick Strahl

@Eric - Thanks. I've updated the post with GetRequestBodyAsString() - also my code :-). I also added a blurp about licensing.
re: West Wind WebSurge - an easy way to Load Test Web Applications
July 29, 2014 @ 7:50am | by Jamie

I've been playing around with this a bit. Love the simplicity. I'm curious if you plan to provide a way to parameterize certain values in the request URL and body? I have a correlation id (Guid) that needs to be sent with a group of requests. It should be unique to each thread and to each group of requests (e.g. four) within a thread. I can make it unique within a thread by generating a session file with unique values. That's tedious, but doable. I don't see a way to make it unique across threads.

Granted, adding in parameterization might remove some of the simplicity you are trying to achieve.
re: Using FiddlerCore to capture HTTP Requests with .NET
July 29, 2014 @ 7:00am | by Eric Lawrence

Hey, Rick-- Thanks for an awesome post!

If you're trying to get the request or response body as a string, you should use the oSession.GetRequestBodyAsString() and oSession.GetResponseBodyAsString() methods respectively. It's not safe to assume that all textual bodies are UTF-8 encoded; these methods will examine the charset declaration in the headers and/or the body when decoding the bytes to a string.

You can get the Fiddler book as a PDF; see

One final caveat: While Fiddler is free for all and Telerik has committed to it remaining so indefinitely, FiddlerCore is provided under a different license with open source and commercial terms. FiddlerCore's license can be found in the installation package.

Thanks again!
re: jQuery Form Serialization without ASP.NET ViewState
July 27, 2014 @ 12:56am | by Mike Gledhill

Excellent tip, great time saver.

Donation sent. Go and have a beer !
re: WebAPI: Getting Headers, QueryString and Cookie Values
July 25, 2014 @ 12:34pm | by me

Thanks for posting this! It is definitely a time-saver and I agree, the API syntax is much more annoying than it used to be for these common requests.

West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2014