Salient Solutions

wrasslin ones and nones for fun and profit - Sky Sanders' Blog
Get your own ranked flair here
posts - 88, comments - 54, trackbacks - 0

AJAX

There are 8 entries for the tag AJAX
Deserializing MS Ajax ClientScript JSON in managed code revisited. e.g. {"d":{"__type":

Overview In a previous post, I proposed a means of deserializing JSON returned from calls to ClientScript endpoints such as XML WebServices decorated with [ScriptService] or [ScriptMethod] attributes, Ajax-enabled WCF Services and WCF services created with WebScriptServiceHostFactory. The use case that prompted this requirement is testing endpoints called by client-side JavaScript. Calling WebScript enpoints in managed code using HttpWebRequest is easy, the trick is to specify content-type 'application/json'. And this is where the problems start. Problem Domain When a WebScript endpoint responds to a request with content-type 'application/json' it understandably assumes that it is being called from JavaScript and, as of 3.5sp1, wraps the actual...

posted @ Tuesday, April 13, 2010 4:44 AM | Feedback (1) |

Adding a ajax/json endpoint to an existing WCF service

Mixing and matching security to get something like this locked down and providing the desired exposure might be challenging but I didn't offer to solve that in the title, did I?    <system.serviceModel>     <behaviors>       <endpointBehaviors>         <behavior name="webScriptBehavior">           <enableWebScript />         </behavior>       </endpointBehaviors>       <serviceBehaviors>         <behavior name="Salient.ScriptModel.Services.DualServiceBehavior">           <serviceMetadata httpGetEnabled="true" />           <serviceDebug includeExceptionDetailInFaults="false" />         </behavior>       </serviceBehaviors>     </behaviors>       <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />     <services>       <service behaviorConfiguration="Salient.ScriptModel.Services.DualServiceBehavior" name="Salient.ScriptModel.Services.DualService">         <endpoint...

posted @ Friday, February 26, 2010 7:04 PM | Feedback (0) | Filed Under [ CodeProject-Tip ]

MS Ajax Minifier 4.0 Simple Web Harness

I have been playing with the MS Ajax minifier and knocked out a simple web harness. It seems to work as advertised. Compression is not as tight as some others but the integration via custom build step and the automation possibilities using the .dll version presents a very compelling case. Get the minifier here. Add this page and a reference to C:\Program Files\Microsoft\Microsoft Ajax Minifier 4\AjaxMin.dll.   <%@ Page Language="C#" ValidateRequest="false" %> <%@ Import Namespace="Microsoft.Ajax.Utilities" %> <script runat="server"> // Webform harness for Microsoft Ajax Minifier 4 // this source code placed in Public Domain by Sky Sanders ...

posted @ Friday, February 19, 2010 9:25 PM | Feedback (0) |

ClientProxyGenerator incorrectly declares all enums as Flag

While writing a barebones js lib to provide intellisense enabled access to WCF JSON endpoints using the /js and /jsdebug mapped endpoints, I came across a bug in System.Web.Script.Services.ClientProxyGenerator. I was wondering why all of the enums that were generated were marked as Flag when they clearly were not. The reason this is an issue is that if you want to .parse or .toString an enum and it is incorrectly marked Flag your results are going to be wrong. The ramifications of this can vary from annoying to disasterous.  Say you want to display people friendly value of an enum returned from a...

posted @ Thursday, February 18, 2010 5:33 PM | Feedback (0) |

WCF to JSON Dates and back again

  I have been struggling with the seemingly unbeatable UTCness of js Date.getTime in respect to dealing with dates going between javascript and wcf. I tried adding the offset/60/1000, munging local times, closing one eye and sticking out my tongue and nothing. nothing. The server was always getting a utc long and treating it as a local. I have been following Rick's saga with wcf dates r.e. ajax and gave his solutions a go and got pleasant results with the .parseWithDate() tweak to json2.js but could not get results with the .stringifyWcf(). Got UTC with no offset no matter how much attention...

posted @ Thursday, February 18, 2010 5:33 PM | Feedback (2) | Filed Under [ CodeProject-Tip ]

JsUnitTest Async Test Pattern

Lately I have been using a lightweight JavaScript testing framework called JsUnitTest. It is quite easy to use but the documentation is non-existent. This is a situation I have begun to remedy by vs-doccing my copy. I may post it soon. In any case, my cursory investigation did not uncover an established async pattern so I wrote a song about it. Wanna hear it? Here it goes........ Listing 1: jsunittest async pattern  /* Jsunittest async runner pattern by Sky Sanders http://skysanders.net/subtext/archive/2009/08/19/jsunittest-async-test-pattern.aspx This pattern enhances standard test runs with the ability to 'pause' the run until the currently running case signals completion. If...

posted @ Wednesday, August 19, 2009 10:41 PM | Feedback (0) |

Salient.Web.Security.AccessControlModule

download source code and demo download this article in .doc format Overview I a previous article I complained about the lack of a true 403 Forbidden error in ASP.NET and the clumsy way that authentication is handled by FormsAuthenticationModule. The solution I came up with was a good first attempt but, in my opinion, came up short. Particularly when handling authentication of requests that ScriptModule touches. So I decided to take another swing at it, this time with some ammunition. I took the list of HttpModules from the root Web.config and the ScriptModule that is added to ASP.NET 3.5 web apps and dove in with...

posted @ Monday, August 17, 2009 10:18 PM | Feedback (1) |

Consuming ASP.net WebServices, WCF Services and static Page methods from JavaScript (sans MS AJAX)

download sample code Overview The Microsoft ASP.NET AJAX platform, known previously as ATLAS and ASP.NET 2.0 AJAX Extensions and fully rolled into ASP.NET 3.5, offers rich functionality but in certain scenarios the the required .ASPX client page and ScriptManager control coupled with the Microsoft Ajax library may conflict with existing requirements or present unnecessary overhead. This document will illustrate that it is possible to leverage the full power of the ASP.NET platform from client script with just a few lines of javascript code on an HTML page. Caveats: This document will not attempt to illustrate a robust...

posted @ Saturday, August 15, 2009 11:04 AM | Feedback (8) |

Powered by: