Last 50 Comments

re: Using plUpload to upload Files with ASP.NET
Yesterday @ 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
Thursday @ 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("http://example.com?key=value");
builder.Query = builder.Query;
Console.WriteLine("Result: " + builder.ToString());
// Result: http://example.com:80/??key=value

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 :
  <system.webServer>
    <httpErrors existingResponse="PassThrough" />
  </system.webServer>


Nice article you have on this : http://weblog.west-wind.com/posts/2009/Apr/29/IIS-7-Error-Pages-taking-over-500-Errors

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.

http://msdn.microsoft.com/en-us/library/system.web.httpresponse.tryskipiiscustomerrors(v=vs.110).aspx
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) {
            alert(ErrorObj.message);
        });


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 ?

tks
PEdro
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 asp.net 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,
                                          Context.Controller.ViewData,
                                          Context.Controller.TempData,
                                          sw);


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;
        
FrameworkElement.LanguageProperty.OverrideMetadata(
   typeof(FrameworkElement),
   new FrameworkPropertyMetadata(
   XmlLanguage.GetLanguage(cultureName)));
 
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());
}

To
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 http://blogs.msdn.com/b/tmarq/archive/2010/05/26/how-extensionless-urls-are-handled-by-asp-net-v4.aspx 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

hi,

It works well with style.

thanks,
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

Hi,

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

Hallo!
nice atricle. I just wondering if you do it the same way in windows 8 like it mentioned at this site.
http://www.excel-aid.com/sign-out-of-a-user-account-in-windows-8-how-and-why.html
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


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