Last 50 Comments

re: Updated ASP.NET Database Resource Provider
Today @ 5:33pm | by Rick Strahl

The provider was designed for SQL Server, but it'd be fairly easy to modify the db access code to work with MySql. The SQL is very standard so if you provide the MySql provider it might just work.

Next update will have better provider support (Mongo and other SQL dialects) but for now you'd have to customize the DB access code.
re: Updated ASP.NET Database Resource Provider
Today @ 12:58pm | by john

Would it be possible to use a MySQL database?
re: Assembly Loading across AppDomains
Monday @ 12:08pm | by Michael Brown

CHOLAN.R is correct. The code loads all dependencies within the parent AppDomain, not in the domain that you created.

AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);

It does not appear possible to load the dependencies in the newly created domain which is rather pointless, and I have not found a workaround for this as of yet. It never fires events on the new app domain (try it):

this.LocalAppDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
re: Web Browser Control – Specifying the IE Version
Friday @ 6:57am | by Joe De Ville

Ahh! I see what I did now. It's javascript embedded in the content I used as a template.

Operator error, as usual. :-)


re: Web Browser Control – Specifying the IE Version
Friday @ 3:36am | by Rick Strahl

@Joe - .innerText should always return text not HTML. If it's returning HTML you like had encoded HTML text in the element in the first place. Maybe the assignment was incorrect (ie. assigning HTML to .innerText).
re: Web Browser Control – Specifying the IE Version
Friday @ 3:12am | by Joe De Ville


Really appreciate all the tips and info over the years. This tip in particular has helped me with an issue that's plagued me for the last several years.

My application of the webbrowser control is not nearly as sophisticated as many of the posters here, but once I edited the registry, I was able to get correct rendering and other behavior in IE 11.

I do still have a problem, though.

The InnerText property of the document now contains (or at least now returns) HTML along with the text, where previously I was able to capture only the text.

Do you know of a simple way to extract only the text (i.e. remove any superfluous HTML?

Thanks for any help.

re: ASP.NET MVC Postbacks and HtmlHelper Controls ignoring Model Changes
September 25, 2014 @ 5:24pm | by Bill Larkin

I puzzled and fought this for a whole afternoon. I didn't even know how to describe the problem and search the Internet for it. But then I stumbled on your write up that explained the problem. Thank you very much for a solution to a problem that was ruining my day!
re: Forcing an ASP.NET Application to 'stay alive'
September 24, 2014 @ 9:34am | by Rick Strahl

@Ron - you get 404 errors from what exactly? There's no reason that the response from an HTTP client wouldn't be same as from a browser unless the URL is incorrect. You may have to hardcode the URL explicitly rather than using relative or virtual paths to specify the URL.
re: Forcing an ASP.NET Application to 'stay alive'
September 23, 2014 @ 3:51pm | by Ron

I tried this in my WebAPI application and it works perfect when I run the app from visual studio, but when I deploy it to QA or PROD I'm getting 404 errors. If I take the same url and run it from the browser it is fine.

How can I fix this?
re: Rendering ASP.NET MVC Razor Views outside of MVC revisited
September 23, 2014 @ 1:11pm | by Rick Strahl

Rodrigo - no this particular code does not work outside of ASP.NET as mentioned in the article. If you need to run completely outside of ASP.NET you can use the Razor Hosting Library:

Takes a little more work to set this up, but you can do most Razor operations easily.
re: A Small Utility to Delete Files recursively by Date
September 23, 2014 @ 1:09pm | by Rick Strahl

Aaron - yes it does normal command prompt wildcards for file selection. And of course you can run it multiple times for varying combinations of deletions if necessary.
re: Rendering ASP.NET MVC Razor Views outside of MVC revisited
September 23, 2014 @ 11:11am | by Rodrigo Pires

Hello Rick,

What if I'm running this code outside an ASP.NET app (meaning no HttpContext available), is it still possible to render the view?

Thank you!
re: A Small Utility to Delete Files recursively by Date
September 23, 2014 @ 9:50am | by Aaron

I haven't downloaded the utility yet, but will it accept various wildcards? I have some people doing massive amounts of testing against a server I've built, creating thousands of files and very strangely named folders each day. Currently I have a dummy script using question marks as wildcards to delete the oddly named folders. They now want the ability to run a script at will that will delete all (specific) files that are older than 2 hours (though I told them I can probably only do days). Hoping your tool will work for me, I'm really not a scripting guy :)
re: A Small Utility to Delete Files recursively by Date
September 22, 2014 @ 1:55pm | by Kenneth Spark

This utility worked great. I needed something to clean up lots of old text files on a regular basis. I tried the forfiles .. but that performed much slower. So slow in fact that the windows scheduler killed the job.
re: UNC Drive Mapping Failures: Network name cannot be found
September 21, 2014 @ 3:51pm | by Struggler

Thanks alot.

I was abaout to throw my computer away and go buy an mac...
re: Accepting Raw Request Body Content with ASP.NET Web API
September 21, 2014 @ 2:53pm | by Highdown

I have been reading your posts on Web API, and they have been very helpful in solving some of my client/server communication issues. Here are two other sites that I have garnered information to deal with uploading/downloading byte[]'s.

I am using TypeScript/AngularJS on the client, and there wasn't much information readily available for something as simple as a byte[] upload/download with Web API. I was used to Silverlight and WCF RIA Services where you could easily upload strings, numbers, and multiple byte arrays in a single server upload.

I have finally been able to get a working client/server setup to upload/download a single byte[]. However, what I was hoping to achieve was to be able to upload more than one byte array at the same time. I do not think the Web API technology is designed to support this, but I could be wrong. Any thoughts?

What I may do is to merge my byte arrays on the client and then break them apart on the server. This is a little messier, but so far it is the only option that I have come up with.

Anyway, thanks for all your posts.

re: Using plUpload to upload Files with ASP.NET
September 19, 2014 @ 9:49am | by Rick Strahl

@Drew - yes the chunk size is configurable and for a reason. If you upload relatively small files you'll want smaller chunks so that the download progress actually has something to show. If you primarily deal with large files though making the chunksize large definitely is a benefit for performance as less connections are needed.
re: Using plUpload to upload Files with ASP.NET
September 18, 2014 @ 9:23am | by Drew H

Hi Rick,

I was able to adapt your plUpload for an application, but I started running into performance problems. To address this I made the chunks larger and I increased the chunk stream size in plUploadFileHandler's OnUploadChunk method as large as .NET will handle for the large object heap, 81920.

Thanks a bunch!
re: A .NET QueryString and Form Data Parser
September 14, 2014 @ 3:14pm | by Andrei Rînea

I did something quite similar to this earlier this year because I needed it in Windows Phone.
re: Prefilling an SMS on Mobile Devices with the sms: Uri Scheme
September 13, 2014 @ 8:28am | by Frustrated

not working on IO7, no fix that I know of. Sucks. If any one has any luck or comes up with workaround, please post.
re: .NET WebRequest.PreAuthenticate – not quite what it sounds like
September 11, 2014 @ 2:59pm | by Bidyut

Out of all the trash available on the WebRequest authentication topic, at various sites , this is the most complete example. It is clear to understand with coherent script flow. I found the following script block to be most useful

"string auth = "Basic " + Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(user + ":" + pwd));
req.PreAuthenticate = true;
req.AuthenticationLevel = System.Net.Security.AuthenticationLevel.MutualAuthRequested;"
re: A .NET QueryString and Form Data Parser
September 11, 2014 @ 12:46pm | by Dan Nemec

This is one of things that I wish was built-in to Uri and UriBuilder (or a URL-specific subclass if query strings aren't well defined in the URI spec). Very, very rarely do you deal with the entire query string as a whole so it makes little sense to treat it as an opaque string.

And while they're at it, they should fix the lack of symmetry in the getter/setter of UriBuilder so extra ?'s aren't added when building a query...

var builder = new UriBuilder("");
builder.Query = builder.Query;
Console.WriteLine("Result: " + builder.ToString());
// Result:

re: I can’t find my Find Dialog in Visual Studio
September 11, 2014 @ 11:12am | by Rich

I found an alternate solution: open the Find window, then immediately go to the "Window" menu at the top and select "Dock" which will pop it into one of your tabbed window sections. Then you can drag it normally into a position of your choosing.

I suspect my window went missing after I changed my monitor configuration (I work on a dock usually, but occasionally, such as last night, I'll work off my laptop screen and a second monitor at home) so the find window could have been on the screen that was no longer there.
re: Setting up and using Bing Translate API Service for Machine Translation
September 10, 2014 @ 7:22am | by SteveIsNotLive

Great stuff as usual. Thanks for sharing!

You were able to login to a Live service without requiring a user to add a name/pw via the Live logon GUI and get the auth token. I stumbled across this post looking for a way to do the same with the Bing Ads API, but it apparently not possible - have you seen a way to automate MS's OAuth2 implementation with WebClient for Bing Ads?

Thanks again, been respecting your stuff since my days of FP 2.6.
re: Routes, Extensionless Paths and UrlEncoding in ASP.NET
September 07, 2014 @ 11:27am | by Rick Strahl

@Jesper - yes, slugs are a good idea for relatively long and unique content. But if you have things like categories or other groups of short named things it's very easy to have slugs with the same name as you're either omitting or converting characters to custom characters, so that can become problematic. Slugs work great for things like page titles, but for meaningful values that need to essentially do a database lookup on and where it doesn't make sense to store the slug in the db it's not such a good idea.
re: Using plUpload to upload Files with ASP.NET
September 05, 2014 @ 4:09am | by Pedro Miguel

Rick tks a lot for the advice. It worked !

Solved with this Web.Config setting :
    <httpErrors existingResponse="PassThrough" />

Nice article you have on this :

good work !
re: Using plUpload to upload Files with ASP.NET
September 04, 2014 @ 2:42pm | by Rick Strahl

I think it has to do with IIS 500 error responses overriding the default content. I think Response.TrySkipIIsCustomErrors would fix that and always return the full response instead of default IIS error pages.
re: Using plUpload to upload Files with ASP.NET
September 04, 2014 @ 12:19pm | by Pedro Miguel

Hi There ,
I Wonder if this problem have ever occur to you.
On localhost i can access error messages generated by ImageUploadHandler.ashx.

When i make the thrown exception with custom message :
throw new Exception("Hey you reached the limmiiitttt");
and i can access it in the JS file with the code :
        uploader.bind('Error', function (Up, ErrorObj) {

all was cool :) but now i've just passed the project to prod environment and the only message i get is "HTTP Error" ...I really don't know where to start to debug the problem, can you advice please ?

re: JavaScript JSON Date Parsing and real Dates
September 04, 2014 @ 3:20am | by Sime

Thanks Rick for such a "sane" and considered article. I especially like the fact that you stress the common-sense approach of avoiding client-side date parsing whenever possible!

We have converted to using the DateTimeOffset data type in all our serverside (database and .NET code). It gives the best of both worlds - local time when you need it and UTC when you don't. We actuallt use DATETIMEOFFSET(0) in the database. This gives the precision we need in the same 8 bytes of storage as a UTC DATETIME.

I found it interesting and heartening to see that JSON / JavaScript is moving towards the ISO8601 standard which actually matches up pretty well with the DateTimeOffset datatype. Also, thanks for the link to moment.js looks very interesting.
re: The broken Promise of the Mobile Web
September 03, 2014 @ 6:29pm | by Bill Kambler

Man, can I ever relate to this!

We've been building out a complex vertical app using mobile first, with focus on phone and tablet as well as desktop interface components. The UI and core features work great on all platforms supported, but we ran aground on simple integration of media access for pictures and video and struggled for weeks on seemingly trivial issues and creating hacky workarounds with bracketed browser specific code. In the end we broke down and used Cordova to get around this mess to build our iOS implementation and we're in the process of creating the Android version now. Making that move was not trivial from our original Web only app either.

It's so painful to be so close, but yet so far away from an all around solution that just works with Web only functionality.

Thanks for the post, Rick - you put into words some of my own frustration and I feel a little better knowing that it's not just our failures in getting it all done with only Mobile Web.
re: ClientBase<T> and a Common Base Class
September 03, 2014 @ 1:44pm | by Lisa B

Thank you! Your post helped me clean up some ugly code!
re: Hosting SignalR under SSL/https
September 03, 2014 @ 7:02am | by Ian

I don't know if I'm missing something but when I tried to use SSL with a self signed certificate my hub connection fails on start with the exception

"The remote certificate is invalid according to the validation procedure."

Is there a way to tell SignalR to not worry about self signed certificates?
re: Creating ASP.NET MVC Negotiated Content Results
August 30, 2014 @ 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
August 29, 2014 @ 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
August 29, 2014 @ 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
August 28, 2014 @ 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
August 28, 2014 @ 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
August 27, 2014 @ 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
August 27, 2014 @ 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
August 27, 2014 @ 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
August 27, 2014 @ 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".

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