Last 50 Comments

re: WebAPI: Getting Headers, QueryString and Cookie Values
Friday @ 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.
re: ASP.NET Frameworks and Raw Throughput Performance
Thursday @ 1:22am | by Nikolai

Thanks for doing this bechmark and amazing results and summary. It was really good to see that ASPX doesn't perform much worse than ASHX.

There's a chance that performance drop over time may be attributed to turbo-boost which is on your 2720QM CPU unless you disable it in BIOS.

The way it works is, once CPU is loaded, it will speed up to 3.3GHz instead of 2.2GHz. However as the CPU potentially gets hotter during the test, there's a chance that it starts to automatically clock down to produce less heat.

Quad-core mobile CPUs are the worst in that aspect as they are in a bucket of design power 45W as opposed to 35W for dual-cores.

What you can do is install a free utility CPUz that will show you CPU speed while you run bechmarks. Or, considering it is Dell, you can actually disable turbo-boost in BIOS just as it seems you already disable Hyper-Threading (which is good to do for consistency of your test). There's also another free tool SpeedFan that can show you core temperatures while you run the test. What you may notice is that just few seconds after you stop the test to IISRESET, core temperatures may drop from ~ 70-80 degrees to ~ 50-60 degrees, thus bumping turbo boost back to max.
re: Nuget Dependencies and latest Versions
Wednesday @ 1:13am | by Pete

Currently experiencing pain because the SignalR package and it's dependencies (specifically OWIN) don't seem to be setup correctly (we had a similar problem a while ago with ODATA). Very very annoying!
re: Allowing Access to HttpContext in WCF REST Services
July 21, 2014 @ 4:30am | by James

What would be nice is a way to access the query string dictionary in the same way you use the params keyword.

However, I guess that then doesn't map well to SOAP?
Does SOAP not have a concept of optional parameters?
re: Hosting SignalR under SSL/https
July 17, 2014 @ 10:39am | by lrpham

Hi Rick, I've been running this HTTPS configuration for a few months without issues but now, messages sent to any specific client does not reach the client. I'm using hubs and is using this method to send the message:


However, when sending a message back to a client caller it works fine using this method:


The only thing that changed recently was the connection string to the database server.
Have you run into this problem with HTTPS ? Thanks.
re: Web Browser Control – Specifying the IE Version
July 15, 2014 @ 2:34am | by Marc

Two of the values for IE10 and IE11 are incorrect in your table (you had 11999, 11000, 10999 and 10000). According to the MS documentation you link to:

11001 (0x2AF9) Internet Explorer 11. Webpages are displayed in IE11 edge mode, regardless of the !DOCTYPE directive.

11000 (0x2AF8) IE11. Webpages containing standards-based !DOCTYPE directives are displayed in IE11 edge mode. Default value for IE11.

10001 (0x2711) Internet Explorer 10. Webpages are displayed in IE10 Standards mode, regardless of the !DOCTYPE directive.

10000 (0x02710) Internet Explorer 10. Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode. Default value for Internet Explorer 10.

Furthermore, you can do this at runtime by writing to HKCU\Software\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION, so long as you write your executable name in before instantiating any web browser controls. When writing to HKCU, you (a) don't need elevated privileges, and (b) don't have to worry about 32 vs 64 bit -- the wow6432node key is not used in HKCU.
re: ASP.NET MVC Postbacks and HtmlHelper Controls ignoring Model Changes
July 12, 2014 @ 11:54pm | by om

very nicely explained and helped me figure out actual problem.
re: ASP.NET Routing not working on IIS 7.0
July 09, 2014 @ 12:18pm | by Todd

This is a great thread going!

@txcraig and others let us to a working solution.

Adding the specific module needed worked for us. We had the "evil" runAllManagedModulesForAllRequests="true" attribute, but didn't want to use it because of the performance concerns (and should you just run all really?). Simply adding the correct module, and removing that evil attribute solved the problem.

We didn't install the patch for Windows 2008 SP2, IIS 7.0 we wanted to try to work around that.

<remove name="BundleModule" />
<add name="BundleModule" type="System.Web.Optimization.BundleModule" />
re: Project Navigation and File Nesting in ASP.NET MVC Projects
July 08, 2014 @ 7:33pm | by Adrian

Good stuff Rick. Especially like the nesting. Jimmy Bogard and his buddy Tim Thomas have written about the same issue and come up with the concept of 'feature folders':
re: Expanding Urls with RegEx in .NET
July 08, 2014 @ 1:10pm | by Josh

In order for the options to work, the last line of the ExpandURLS function would need to be modified as following:

    Public Function ExpandUrls(Text As String) As String
        Dim pattern As String = "([""'=])?(http://|ftp://|https://|www\.|ftp\.[\w]+)([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])"
        ' *** Expand embedded hyperlinks
        Dim options As System.Text.RegularExpressions.RegexOptions = RegexOptions.IgnorePatternWhitespace Or RegexOptions.Multiline Or RegexOptions.IgnoreCase
        Dim reg As New System.Text.RegularExpressions.Regex(pattern, options)
        Dim MatchEval As New MatchEvaluator(AddressOf Me.ExpandUrlsRegExEvaluator)
        Return Regex.Replace(Text, pattern, MatchEval, options)
    End Function

re: Dynamic Types and DynamicObject References in C#
July 07, 2014 @ 9:03am | by Joy

Good stuff, just what I was looking for :D
re: Dell XPS 15 review
July 07, 2014 @ 1:25am | by krystan honour

I saw this review and it cermented my decision to buy. I echo your sentiments about keyboard and after I'd read the reviews about the Lenovo X1 2nd gen I couldn't in all conscience buy the lenovo purely because of the keyboard.

however the xps15 looked like a great bit of kit and its being delivered tomorrow. Thanks for the great review and the driver pages.
re: WCF WS-Security and WSE Nonce Authentication
July 06, 2014 @ 11:22am | by John Herron

Hi Rick - I'm getting an h:Security section before the o:Security section. The web service I'm calling fails because of this with a "user could not be authenticated" error. If I capture the message with fiddler then remove the section or change the h:Security spelling it works. Did you remove the section from your post or does it include it? I need a way to remove the h:Security section.

re: WCF WS-Security and WSE Nonce Authentication
July 06, 2014 @ 9:41am | by Scott Eastin

I just wanted to say this article was a giant help. There is barely anything out there about how to solve these types of problems and this article was the solution to the developer hell I have been in for the last week. Thanks again and I owe you several beers!

re: Use IIS Application Initialization for keeping ASP.NET Apps alive
July 02, 2014 @ 11:27am | by Rick Strahl

@Sunil - All of what's described - except for the startup hook callback - are IIS features so they work on any kind of site regardless of backend technology including ASP classic.
re: Use IIS Application Initialization for keeping ASP.NET Apps alive
July 02, 2014 @ 9:25am | by Sunil

Hi Rick,

What is the Impact of this on a Classic ASP web site. I normally keep idle time-out to 0 still if you don't use the site for a long time ( mainly test sites) you will see that it takes some time to start.


re: Project Navigation and File Nesting in ASP.NET MVC Projects
July 02, 2014 @ 8:23am | by Rick Strahl

@Bob - yup I mentioned in the post I've played with putting the controller into the Views folder for that controller. I've done that in a few projects as well - just dropped the controller into the Views folder. But I find the controller much less of a distraction even in a different folder because there's typically one controller for many views and usually I'm not opening controllers all the time as they just stay open. In a typical work scenario I'm working on one controller at a time, but views OTOH I often work on several at the same time frequently. Agree though - if that makes sense to you, by all means go for that.

I do like the Views folder though. If you want to not have to reference views explicitly by path then the Views folder makes sure MVC finds them by convention. You can change the base folders but the structure still has to stay kind of the same, and to me that more or less makes sense.

If you do something different what is the layout that you use that is different enough to make this better? I'm curious...

Finally if you do move/rename the Views folder to something else do make sure that you protect the .cshtml files. I believe IIS protects that anyway though because of ASP.NET WebPages using them in the first place.

re: Project Navigation and File Nesting in ASP.NET MVC Projects
July 02, 2014 @ 8:11am | by Rick Strahl

@Ventsi - you can leave the handler in there but just exclude .cshtml files (or .vbhtml if using VB).

<add name="BlockViewHandler" path="*.cshtml" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />

I totally spaced that I changed this in the project. Adding to the article. Thanks for catching that!

Note that you shouldn't remove the handler - otherwise ASP.NET will try to execute the .cshtml pages as ASP.NET WebPages which would cause unexpected behavior.

re: Project Navigation and File Nesting in ASP.NET MVC Projects
July 02, 2014 @ 12:36am | by Ventsi

@Rick I found the problem: in latest versions of ASP.NET MVC there is a blocker in web.config not to server any content from Views folder :
      <remove name="BlockViewHandler"/>
      <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />

I need to remove the handler to enable serving static files from Views folder.
re: Project Navigation and File Nesting in ASP.NET MVC Projects
July 01, 2014 @ 11:40pm | by Jonathan

I put my login.js into a bundle and it works. I did read that part above about a problem with this and bundling but I wanted the best of both worlds. I'm interested to know how you didn't have a problem, or if there is something you had to turn off or is it just because you don't use any bundling. I'll keep digging. Thanks for the article. I'm always looking for a better way to do things.
re: Project Navigation and File Nesting in ASP.NET MVC Projects
July 01, 2014 @ 11:24pm | by Jonathan

I've done something wrong I guess. I tried this out with my login.cshtml and a login.js in my Views/Account folder. When I run it I get a 404 on the login.js. I can move the login.js out of the Views/Account folder (first un-nesting) and it works fine. It feels like it has a problem referencing js out of the Views folder, but I thought that was what you were doing above.
<script src="~/Views/Account/Login.js"></script>

Interestingly enough, I use Areas and in each area I have a js folder and that works fine. I like the js folder inside each area for a specific areas js, but I would like to use the nesting and clean up some of the base code.
re: Project Navigation and File Nesting in ASP.NET MVC Projects
July 01, 2014 @ 10:55pm | by PilotBob

I never liked having a single folder for controllers either with the views way over in another folder. We have tried creating controller folders like we do with views, but this got pretty busy.

I just prefer to have the controller and all it's views in the same folder. But, I don't like that folder being called views or controllers. You can modify the view engine so you can specify the folder that it probes for views. But, leaving it as views works. So, drop the controllers folder and put them in the views folder. It is much cleaner.

Also, I leave script and content as they are. I don't have a problem with them, and NuGet expects them there. But, for our own js I prefer it to not be in scripts, so I create a js folder, but app could work as well. However, I think app is too general. But, whatever works.
re: Project Navigation and File Nesting in ASP.NET MVC Projects
July 01, 2014 @ 9:59pm | by Rick Strahl

@Chris - even before changing to this particular layout I've not been using the content folder. I've always thought that a lame abstraction. For client side libraries and CSS etc. I tend just download the files from the source and replace them or as you say move them. It's easy enough to do especially if you don't use the content folder for other things.

Yup it'd be nice if you could specify where things go, but really this would have to be dynamic and would require some UI to choose where things go. I don't think there's really an easy one location fits all solution that really addresses all needs. You'd almost need to have a NuGet configuration for each package to make that work. I see the issue. That's why tools like Grunt and Gult exist for NPM/Node - they allow to really customize via a simple code flow where things go. NPM works, but it's also another set of tooling which kind of sucks as well. As it is it seems we're having to rely on too many components to make everything work. Too many diverse technologies just to get the build to go... sigh. I don't see this getting any easier either - it'll get more complex before it gets easier I think. Just look at the Node space to see where this is all headed at the moment. Looking at 1000 line Grunt files is not my idea of fun :-)

@Prabu - For minification I actually just rely on Web Essentials. Page specfic scripts I don't bundle because they're usually one off. Application level scripts I either use the MVC bundling (not a fan though because of all the dependencies that adds to a project), or external tooling like Grunt or in the future Gulp. There are a lot of choices.

I'm hoping the native story for this will get better in VS. Personally I wish there were better automation tooling that worked directly out of VS, but for now I'm firing off Grunt tasks from the build to do this. It works but is yet another toolset to add to everything. I would use bundling but I'm really unhappy with the proliferation of assemblies that adds to your project which impacts load size and startup time. A lot of the startup bloat for MVC comes from all the bundling mess.

re: Project Navigation and File Nesting in ASP.NET MVC Projects
July 01, 2014 @ 8:07pm | by Prabu

Great post - it is something I've been thinking about as well.

A quick question that's slightly off topic regarding the client centric SPA apps that use pure HTML templates. How do you incorporate bundling and minification for the css/js files in them with VS.

I tend to use a MVC project to leverage these features OOTB but they require the use of .cshtml files.
re: Project Navigation and File Nesting in ASP.NET MVC Projects
July 01, 2014 @ 5:30pm | by Chris Hynes

How do you handle NuGet package updates that include ~/Content files? Just move the files around?

One of these days NuGet's going to add a configuration for content file locations, but there doesn't seem to be much consensus on the best way to do it:
re: Project Navigation and File Nesting in ASP.NET MVC Projects
July 01, 2014 @ 10:08am | by Chris Johnson

Makes sense to me. I have a WPF application with similar pain, and I've found it helpful to create a top-level "MainClasses" folder with all the classes that I have to touch regularly (with subfolders as needed) and a top-level "UtilityClasses" folder that I can stick stuff in that don't normally need maintenance so that I can hide them until I need them. Unconventional, yes, but it helps me work faster. When I hand the project off to someone else at some point in the future, they can re-arrange the files to their heart's content.
re: Project Navigation and File Nesting in ASP.NET MVC Projects
July 01, 2014 @ 9:18am | by Rick Strahl

@Ventsi - I rarely use areas so I didn't check but I think that should work. Can you access other content cross areas?
re: Project Navigation and File Nesting in ASP.NET MVC Projects
July 01, 2014 @ 3:47am | by Ventsi

Hi Rick,
What if we use Areas, I'm trying with
  <link href="~/Areas/Common/Views/ControllerName/viewName.min.css" rel="stylesheet" />

   <script src="~/Areas/Common/Views/ControllerName/viewName.min.js" type="text/javascript"></script>

with no success, maybe we should register some routes.
re: Updated ASP.NET Database Resource Provider
June 30, 2014 @ 11:28am | by Rick Strahl

@Developer - for the client side I tend to generate strongly typed resources (part of the globalization toolkit)

and just use those directly using object names. This works as long as the resource IDs are safe JavaScript names.

var hw = Resources.HelloWorld;
// non type-safe name
var hw2 = Resources["Hello World 2"];

I also tend to create a DbRes.T() function in my apps that matches the behavior of the server class - where you can specify the name of the resource and resources set. This has been valuable when server side MVC style localization expressions to the client side

// server expression
Text: @DbRes.T("HelloWorld","Resources")
// client expression
Text: {{DbRes.T("HelloWorld","Resources")

The client side version simply exposes a global object/function that looks at the resources and objects that I've attached to a fixed location.

As to auto-assigning stuff - not a fan of that myself. There are too many things you need to consider such as naming coinventions, properties/attributes that values get assigned to etc. plus it won't really work if you use dynamic controls with things like Angular. I think it's simply better to be explicit about resource assignment.
re: SmtpClient and Locked File Attachments
June 30, 2014 @ 8:19am | by Vishnoo Rath

This is a life saver. Had me wondering where I was going wrong, until I saw that the original coder had not disposed the MailMessage object.

Localized strings to Html
June 30, 2014 @ 4:59am | by Developer

Hi Rick, thanks for this great direction, whats your thoughts on applying the localized strings to HTML using javascript plugin or using some generic handler?

I mean Dres.T version in javascript which will detect all applicable controls and replace in one shot.
re: A dynamic RequireSsl Attribute for ASP.NET MVC
June 28, 2014 @ 12:18pm | by Rick Strahl

@Steven - After the comments here I took a quick look to see what's involved in using IOC with a filter and it looks like doing IOC with a filter would be pretty tough to do *generically*.

Looking at some of the threads on StackOverflow it appears that constructor injection in general doesn't work - you need to use property injection at which point you start depending on specific IOC container dependencies to mark the property as injectable.

Has anybody done something along these lines? How would you create a generically injectable attribute that works with any IOC container for a filter?
re: Filtering List Data with a jQuery-searchFilter Plugin
June 26, 2014 @ 6:56pm | by Rick Strahl

@2bitcoder - for that you would be better off manually writing the logic. As you're hinting in your code you would need two selectors, one to search, and one to show/hide items. What you'd do is find your targets, then walk up to the show/hide selector and show those - hide all the other ones before.
re: Filtering List Data with a jQuery-searchFilter Plugin
June 26, 2014 @ 4:53pm | by 2bitcoder

How would I have a separate searchable div to the div that is hidden. In the case where I only want a certain sub div text to be looked at in the search.

<div class="time-entry">
<div class="time-entry-right">
May 11, 2014 - 7:20pm<br />
<span style='color:steelblue'>0h:40min</span><br />
<a id="btnDeleteButton" href="#" class="hoverbutton" data-id="16825">
<img src="images/remove.gif" />
<div class="punchedoutimg"></div>
<div class="searchable">
<b><a href='/TimeTrakkerWeb/punchout/16825'>Project Housekeeping</a></b><br />

$("#txtSearchPagePlugin").searchFilter({ targetSelector: ".searchable", hideSelector: ".time-entry", charCount: 1 })
re: AspNetCompatibility in WCF Services – easy to trip up
June 26, 2014 @ 1:42pm | by Scott Hannen

Thank you. Thank you very, very, very much. Really, thank you.
re: A WebAPI Basic Authentication Authorization Filter
June 26, 2014 @ 10:35am | by Philip Raeburn

Hi Rick, I implemented a Web API with Basic Authentication and SSL using a similar approach to yours and requiring https. I have managed to get this working in my Development environment( 2013) and when I run it I can see the encoded credentials using Fiddler. I deployed the API to one of our servers and when I access the API using a URL it prompts me as expected for Username and Password and after entry works as expected. However when I try to access the API using the JQuery/JavaScript client(below) I used in development I keep getting a 401 error and when viewing in Fiddler it doesn't seem as if those credentials are being passed to the API. Any ideas why this is happening?

function TestData() {
type: "GET",
url: "",
success: function (result) {
if (result) {
else {
beforeSend: function (xhr) {
"Basic " + btoa("username" + ":" + "password"));

re: Prefilling an SMS on Mobile Devices with the sms: Uri Scheme
June 25, 2014 @ 2:49pm | by Brandon

For some reason sms:?body= links will not open correctly from chrome on android, but just fine from Firefox on android. I am using Hangouts for SMS. Any ideas on how to fix?
re: Web Browser Control – Specifying the IE Version
June 24, 2014 @ 11:30am | by Todd Morrow

ok let me answer my own question...

yes, this is possible, by hosting multiple exe's in the main exe.
re: Web Browser Control – Specifying the IE Version
June 24, 2014 @ 11:18am | by Todd Morrow

Hi Rick,

I'm trying to have a single winforms application with a tab control that displays a different IE version in each tab. Yep at the same time.

If I could "fake" the application name depending on what tab I was on that would do the trick.

When IE control goes to load a page, I'm sure it checks the registry with the name of the exe that it finds itself in, correct? So I want to hack / fool that API call.
re: WCF WS-Security and WSE Nonce Authentication
June 23, 2014 @ 9:31pm | by Dennis

@Steve - the simple rawnonce is what made the difference for me. This page helped confirm I was on the right track. You comment made it work. I have been only trying for 10 hours so far to get this all to work. The last 5 was this one issue. I was trying in a language I never used before (apex, salesforce) and thanks to your comment was able to do so.
re: .NET HTML Sanitation for rich HTML Input
June 23, 2014 @ 1:27pm | by Jonn

Codes broken. If you don't close the tag, it isn't parsed properly and then it gets closed off for me. For example:

<script src=""

Is allowed through (and the src attribute is doubled for some reason) with /> appended to the end to make it a valid tag.
re: Building a better .NET Application Configuration Class - revisited
June 23, 2014 @ 10:08am | by Rick Strahl

@Brian - I don't think that's bad form at all - in fact that's how I set up most of my applications. The business layer holds the configuration settings and then exposes the App class with the static Configuration member to the top level application (Web, Win, Service - whatever). The main application can then reference the public static App.Configuration property (or whatever) whenever it needs configuration settings.

Implementation in a class library is no different than in the main project. I'd argue this is the correct way to do this - config settings belong in the component that uses those settings and typically that's not the front end application but the 'business' layer.

This setup works even with multiple configurations in separate class libs,  because each config can get its own section or file so even if you had multiple class libraries they can all store config settings without stepping on each other. I use this configuration setup for all of my business object assemblies and a bunch of my custom components. It works for all of it.

Implementation the same regardless where you implement. Config settings (if you're using .config files anyway) always go to the main application's configuration file regardless which assembly it came from. So yes - create your config class subclassed from AppConfiguration and simply expose a static to it somewhere so it's accessible to your component and/or publicly to the main application. For business apps a public class can be used. For a component that hides its implementation, internal scope can be used.

Hope this helps.

re: Building a better .NET Application Configuration Class - revisited
June 23, 2014 @ 8:02am | by Brian

I know it's bad form, but if I need access to configuration settings in a class library project, referenced by my main web application project, what would be the best way to implement this technique?

Would I just implement it in the class library project? Implement a base type in the class lib project with the settings used in there and derive in the web app project with the rest?
re: Nuget Dependencies and latest Versions
June 23, 2014 @ 5:22am | by Andrew Miller

I've been struggling with this same issue, and finally came across info about why they made this change to NuGet, in the v2.8 release notes:

I agree it's a pain in our situation, but I understand why they made the change.
re: Nuget Dependencies and latest Versions
June 21, 2014 @ 4:12pm | by Sean

Agree with all of this. NuGet is fast becoming the new Dll-Hell.
re: Monitoring HTTP Output with Fiddler in .NET HTTP Clients and WCF Proxies
June 21, 2014 @ 2:20am | by Mahesh

Hi all,
I have an application deployed on our app and web server which consumes different web services,wcf and MQ services from different down stream applications and I am accessing my application on my local machine,can someone help me how can I get what are all the web services or wcf Services and MQ services and request and response which are used in my application on my local machine?
re: Passing multiple simple POST Values to ASP.NET Web API
June 20, 2014 @ 12:58pm | by Grant Erickson

I may have missed something, but I was having issues with optional parameters. I added the following code to take care of it.
        public override Task ExecuteBindingAsync(ModelMetadataProvider metadataProvider,
                                                    HttpActionContext actionContext,
                                                    CancellationToken cancellationToken)
            object value = StringToType(stringValue);
            // Handle optional values.
            if (value == null && this.Descriptor.IsOptional) 
                value = this.Descriptor.DefaultValue;
            // Set the binding result here
            SetValue(actionContext, value);

re: Nuget Dependencies and latest Versions
June 20, 2014 @ 6:04am | by Steven Maglio

It looks like the FubuMVC project also ran into issues with the way NuGet versioning resolves. They attempted to work around the problem by building a product called Ripple. I don't believe they were focused on the use case where there's an upper limiter on the version number, so I don't know if they added that feature. But, I believe the project is still under active development; so it could probably be added.

If you're interested, check out the "Enter ripple restore for cascading builds" section of
re: Forcing an ASP.NET Application to 'stay alive'
June 20, 2014 @ 3:56am | by Murali

Thanks for writing this Great article!!

I believe your approach will be the best solution for me. I am using Quartz.Net in my application and we are ending up with IIS recycling and it stops working.

We hosted our application in external hosting provider, so we cannot play with config file explained

Let me try your approach and solve my problem.
re: Nuget Dependencies and latest Versions
June 20, 2014 @ 1:20am | by Dennis

I think they did the lowest version number, based on that you will mark the the older versions as deleted/removed on the feeds, this way you choose what the lowest version is publically available for install, but restores with older versions still Work.


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