Last 24 Comments

re: Integrating OpenID in an ASP.NET MVC Application using DotNetOpenAuth
Saturday @ 8:50 am | by Shyju

Is there any workaround if the server time is behind UTC time, My code is returning an error saying the the "The message expirefd at XXXX time and the server time is XXXXX. Obviously because the Server time is behind the UTC time. My hosting (shared) is not ready to change their server time.
re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
Friday @ 2:52 pm | by leo_21

I was loosing hope and thinking I'd had to reinstall IIS but thanks to you I've got it fixed so many thanks. In adition to your port the modiffication can be done not only over the website but over the whole server just choosing the server and then the Configuration Editor so if one adds new pages then, they won't get misconfigured cause the global config should be fine, many thanks for this post, as some said this post should be the first result google must show.
re: HttpWebRequest and GZip Http Responses
Friday @ 3:10 am | by vipul


Hi Rick
I just convert your cod in vb.net and use for gzip http response and request. but my case it is throwing Error " The remote server returned an error: (500) Internal Server Error."

Please Help me. In xml http request response it is getting 150 to 200 Second.


Protected Function PostXml(ByVal url As String, ByVal xml As String) As String
Dim strResult As String = String.Empty

Try
Dim Http As HttpWebRequest = WebRequest.Create(url)

Http.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate")

If Not String.IsNullOrEmpty(xml) Then
Http.Method = "POST"
Dim lbPostBuffer As Byte() = Encoding.Default.GetBytes(xml)

Http.ContentLength = lbPostBuffer.Length

Using PostStream As Stream = Http.GetRequestStream()
PostStream.Write(lbPostBuffer, 0, lbPostBuffer.Length)
End Using
End If

Using WebResponse As HttpWebResponse = Http.GetResponse()

Dim responseStream As Stream = WebResponse.GetResponseStream()

If (WebResponse.ContentEncoding.ToLower().Contains("gzip")) Then
responseStream = New GZipStream(responseStream, CompressionMode.Decompress)
ElseIf (WebResponse.ContentEncoding.ToLower().Contains("deflate")) Then
responseStream = New DeflateStream(responseStream, CompressionMode.Decompress)
End If

Dim reader As StreamReader = New StreamReader(responseStream, Encoding.Default)

Dim html As String = reader.ReadToEnd()

responseStream.Close()

Return html
End Using

Catch ex As WebException
strResult = ""
End Try
Return strResult
End Function
re: .NET 4.5 is an in-place replacement for .NET 4.0
Thursday @ 10:40 am | by Mike

To your point about being able to run .NET 4.0 applications on .NET 4.5 - I found at least one issue:

I was just playing around with a annoying behaviour with the WPF datagrid that was changed on the last release of the WFP Toolkit and made it into .NET 4.0: http://wpf.codeplex.com/workitem/13022

In .NET 4.5 the behaviour has been changed to not set the SelectedItem to null when the DataGrid is disabled (yeah!)

However, now when I create a WPF application targeting .NET "4.0" the behaviour will be different depending if .NET 4.5 or .NET 4.0 is installed on the client machine... yikes! Not really 100% backward compatible.
re: DropDownList and SelectListItem Array Item Updates in MVC
Thursday @ 8:40 am | by Javier Callico

I had a similar issue myself also caused by an static list of items been used across different requests (threads). Thanks for sharing your solution.
re: DropDownList and SelectListItem Array Item Updates in MVC
May 16, 2012 @ 12:58 pm | by Larry

looks like there's also a [ReadOnly(true)] attribute you can put on the model itself, so you have it in one place rather than having to find every action method where it's used and use [Bind]:

http://odetocode.com/blogs/scott/archive/2012/03/11/complete-guide-to-mass-assignment-in-asp-net-mvc.aspx

but I agree, in your case, it's probably best to fix the source
re: DropDownList and SelectListItem Array Item Updates in MVC
May 16, 2012 @ 12:30 pm | by Rick Strahl

@Larry - that might work, but the list is used in number of places so it becomes tedious and unobvious that this is required - I think it's better to fix this at the source rather than special casing in the actual controller methods which is easy to forget.

FWIW, I didn't know that you can actually do that or what the syntax for this looks like - good to know. This might actually make a lot of sense for other scenarios.
re: DropDownList and SelectListItem Array Item Updates in MVC
May 16, 2012 @ 12:23 pm | by Larry

could you not use the POST Action Method's Bind attribute to exclude the model.CategoryList property from the model binder, since you're refetching it from cache anyway?

would that prevent it from updating the CategoryList while still allowing it to set model.QueryParameters.Category?
re: DropDownList and SelectListItem Array Item Updates in MVC
May 16, 2012 @ 12:05 pm | by Larry

could you not use the Action Methods Bind attribute to exclude the model.CategoryList property from the model binder, since you're refetching it from cache anyway?
re: DropDownList and SelectListItem Array Item Updates in MVC
May 16, 2012 @ 11:40 am | by Rick Strahl

@Vova - No it's an issue in all versions of MVC - just so happens this is the first time I've stumbled into this. The reason the ModelBinder 'knows about' the cached list is because a reference to it is on the model that I'm binding to - I'm passing it out of the GetCachedCategories() function which originally simply returned the static list. My assumption was that the SelectList[] was read only - but the ModelBinder actually updates the list if it's bound. Actually I'm not sure whether this is the binder's doing or the Html.DropDownlist() helper which assigns the value once it knows what the selected value/values from the model/Postback are. Something sets the Selected value of the item selected between the two. It'd be interesting to look into the code for ListBox/DropDownlist helpers.

@Amit - yes I was thinking about caching the domain object originally, but since I only needed a couple of values rather than a full entity and 100% of the use cases involve a drop down list I decided to return the SelectList[] instead.
re: Web Browser Control – Specifying the IE Version
May 16, 2012 @ 11:33 am | by Rick Strahl

@kobik - I haven't figured out a way to do this at runtime. I suppose it is possible since the IE Tools let you switch the engine on the fly but I have no idea how that can be done. As far as I can tell the values are read only when the engine is created in an app for the first time.
re: Web Browser Control – Specifying the IE Version
May 16, 2012 @ 10:57 am | by kobik

@Rick, very good post! Thanks.

The main problem I'm trying to solve, is how to SWITCH modes at run-time (like IE developer tools does).

My application itself (not the installer) updates the registry as done by @Asdf (since I write to HKCU there is no UAC issue). I'm also using Delphi btw.

But the problem is how to refresh/reload the WB control and tell it that the registry setting were changed... It seems that the key value is read by the FIRST instance of the WB control that was created by the application. so even, If you destroy the control, change reg value , and create a new instance, the old value is preserved until you restart your application.

Maybe there is an Exec command for this, or a special message?

Any ideas?
re: DropDownList and SelectListItem Array Item Updates in MVC
May 16, 2012 @ 9:54 am | by Amit

This is a typical problem even if using Cache. If the object from cache is returned as is (without cloning) and for some reason the returned object is modified (in this case by ModelBinder), the original object in the Cache is modified. I have also run into this.

On the side note, I prefer to cache the domain entity (in this case categories) instead of the select list, as then it can be used in other places as well.
re: DropDownList and SelectListItem Array Item Updates in MVC
May 16, 2012 @ 7:55 am | by Vova

Interesting. So, is it MVC4 specific issue? And how ModelBinder would know about the cached list? Form what I can see, when it binds received (form) data to view model there are no items in SelectList, so it can set only SelectedValue property. How it managed to track depndencies between your static (cached) variable and SelectList in view model?
re: DropDownList and SelectListItem Array Item Updates in MVC
May 16, 2012 @ 3:42 am | by Rick Strahl

@TheSaintr - yes Cache would work, but as I mentioned that list so rarely changes that it really doesn't matter. It wouldn't really change the logistics and I prefer not tying things to the HttpContext pipeline if I can avoid it :-)
re: DropDownList and SelectListItem Array Item Updates in MVC
May 16, 2012 @ 3:38 am | by TheSaintr

Why don't you use Cache instead of static object..

Doing so you can "clear" that cache item to refresh... with static you have to restart/recycle your site
re: Passing multiple POST parameters to Web API Controller Methods
May 15, 2012 @ 2:02 pm | by Rick Strahl

@Jonathan - sure. You need to be able to JSON encode - meaning you need Json.net or System.Json to provide the parsing. The new System.Net.Http library also includes a host of methods that make it easy to call JSON and XML endpoints and provide the type marshalling required to use the data sent and returned more easily.
re: Passing multiple POST parameters to Web API Controller Methods
May 15, 2012 @ 1:24 pm | by Jonathan

How would you make a call to this type of Web API from a WinForms app? Is that even possible. Thanks.

Jonathan
re: Problems with opening CHM Help files from Network or Internet
May 15, 2012 @ 5:54 am | by Tony

For those who can't access the 'Unblock" option,

Make sure the file name does not contain the '#' sign or even the folder name of the folder it's contained in.

Have a look at the post I've linked below.

http://saifulmuhajir.me/2011/01/23/solve-i-cant-open-chm-files-in-windows-7/

:)
re: ActiveX component can't create Object Error? Check 64 bit Status
May 15, 2012 @ 5:21 am | by Aniruddha

Hi,

i tried your solution, now i m able to create object for active X component, but
i m not able to debug the same in VS2010.

i m using classic asp pages and VB6 dll.

please give me a solution to this.
re: Error on 64 Bit Install of IIS – LoadLibraryEx failed on aspnet_filter.dll
May 14, 2012 @ 6:55 am | by Sudarsan

It is a great article. Thank you very much for posting. It worked like a charm and saved my life..
re: Passing multiple POST parameters to Web API Controller Methods
May 09, 2012 @ 11:37 pm | by Rick Strahl

@BackToTheFuture - what browser are you using? If you're running older browsers you'll have to add json2.js to your script includes. Newer browsers (IE9, FF, Chrome, Opera) all support native JSON conversion. Note it's also case sensitive so the method JSON.stringify().
re: Passing multiple POST parameters to Web API Controller Methods
May 09, 2012 @ 8:54 pm | by BackToFuture

For me the JSON.Stringify does not work it returns null movie and 01/01/0001 as date


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