Wednesday, February 29, 2012

TFS 2010: Go offline

TFS 2010 support offline clients. This means that you can continue to work although the TFS connection is not available. So if you start up VS and attempt to load a project contained in TFS and TFS cannot be found then VS will prompt you to work in offline mode.

TFSGoOffline

There is only one problem: VS only does this when loading a solution.  If TFS goes offline while a solution is already open though VS will not switch to offline mode.  Instead it'll keep trying to connect to TFS and then time out.  This is really inconvenient. 

So how can we tell TFS to go offline without having to reopen Visual Studio?

I’m aware of 2 options:

TFPT.exe
  • Open a Visual Studio 2010 command prompt
  • Run tfpt.exe with the ‘tweakUI’ option
  • Select the appropriate server and click Edit.
  • In the server properties dialog, check the Server is offline checkbox and click OK.
  • Now VS is in offline mode.  This takes effect immediately (even if VS is already open). 
Go offline extension
  • In Visual Studio go to File –> Source Control.
  • An extra Go Offline button should show up.

Remark: TFS 11 and VS 11 will support a far better model to work offline. 

Tuesday, February 28, 2012

Ajax request returns status 0

Last week our users reported a bug that they got an alert window in their browser showing 0(zero). We traced the problem back to the following JavaScript code:
$.ajax({         
 type: "POST",         
 url: $(this).data('targetUrl'),         
 cache: false,         
 success: function(data){                 
  //Do something         
 },     
 error:function (xhr, ajaxOptions, thrownError){
        alert(xhr.status);             
  alert(thrownError);     
 }        
});

The alert window shows the following message 0 and ‘undefined’.

We found out that this could happen if the ajax request is getting canceled before it completes. We could reproduce the problem if we triggered the ajax request and then immediately click on a link to navigate away from the page. jQuery throws the error event when the user navigates away from the page either by refreshing, clicking a link, or changing the URL in the browser.

We fixed the issue by introducing a global error handler for the ajax call, and inspecting the xmlHttpRequest object:

$(document).ajaxError(function(e, jqxhr, settings, exception) {
  if (jqxhr.readyState == 0 || jqxhr.status == 0) {
    return; //Skip this error
  }
});

Monday, February 27, 2012

Just announced: TFS Express

Just before the availability of  VS/TFS 11 Beta, Microsoft introduces a new download of TFS, called Team Foundation Server Express, that includes core developer features:

  • Source Code Control
  • Work Item Tracking
  • Build Automation
  • Agile Taskboard
  • and more…

It’s a FREE version of TFS for individuals and teams of up to 5 users.

The Express edition is essentially the same TFS as you get when you install the TFS Basic wizard except that the install is trimmed down and streamlined to make it incredibly fast and easy. In addition to the normal TFS Basic install limitations (no Sharepoint integration, no reporting), TFS Express:

  1. Is limited to no more than 5 named users.
  2. Only supports SQL Server Express Edition
  3. Can only be installed on a single server (no multi-server configurations)
  4. Includes the Agile Taskboard but not sprint/backlog planning or feedback management.
  5. Excludes the TFS Proxy and the new Preemptive analytics add-on.

More users can be added by buying Client Access Licenses (CALs) for the additional users. And even upgrading to a full TFS license is supported without losing any data.

Another thing I noticed is that Microsoft finally enabled TFS integration in their Visual Studio Express products. The Visual Studio Express client integration with work with any Team Foundation Server – including both TFS Express and the Team Foundation Service. No excuses left to not start using TFS.

Installation of TFS Express will be done by just clicking on a link, running the web installer and you’re up and running in no time.

Maybe there will be a free version of Team Foundation Service too?

And here is the link to the official blog post by Brian Harry: Coming Soon TFS Express.

Friday, February 24, 2012

SQL Server Profiler: Trace events from one database

I always seems to forget how to configure SQL Server Profiler to trace only a specific database. So therefore this post.

  • Open SQL Server Profiler
  • Click on New Trace.
  • Connect to the database server you want to trace.
  • The Trace Properties window is shown. Go to the Events Selection tab.

image

  • On the Events Selection tab select show all columns.

image

  • Now you have an extra column DatabaseName.

image

  • Click on Column Filters… to add a filter. Specify the name of the database in the Like section.

image

  • That’s it!

Thursday, February 23, 2012

When can I use… Compatibility tables for support of HTML5, CSS3, SVG and more in desktop and mobile browsers.

You have to target a specific browser and you want to know if this browser supports a feature or not? The Can I Use website is the only thing you need.

image

Just enter the name of a feature (e.g. Geolocation) in the Search box and you’ll get a nice overview with all the browsers(including mobile versions) and their support.

image

Remark: I still recommend to use feature detection inside your web application(with Modernizr for example).

Wednesday, February 22, 2012

WCF Extensibility

This becomes really the week where I found a lot of great resources on the web. Today I discovered the perfect post to learn everything about WCF Extensibility.

Extensibility

Carlos Figueira has written a series of posts about the (many) extensibility points from WCF (up to .NET Framework 4.0). Great stuff!

Table of Contents

1. Service model extensibility
1.1. Behaviors
1.1.1. IServiceBehavior
1.1.2. IContractBehavior
1.1.3. IEndpointBehavior
1.1.4. IOperationBehavior
1.2. WCF Runtime
1.2.1. Message interception
1.2.1.1. I[Client/Dispatch]MessageInspector
1.2.1.2. IParameterInspector
1.2.2. Mapping between message and operation parameter
1.2.2.1. I[Client/Dispatch]MessageFormatter
1.2.3. Mapping between message and CLR operations
1.2.3.1. I[Client/Dispatch]OperationSelector
1.2.3.2. IOperationInvoker
1.2.4. Instance [context] creation / initialization
1.2.4.1. IInstanceProvider
1.2.4.2. IInstanceContextProvider
1.2.5. Error handling
1.2.5.1. IErrorHandler
1.2.6. Others
1.2.6.1. Initializer interfaces (IInstanceContextInitializer / IChannelInitializer / ICallContextInitializer)
1.2.6.2. IInteractiveChannelInitializer
1.3. Exposing / consuming metadata
1.3.1. IWsdlExportExtension
1.3.2. IWsdlImportExtension (and IOperationContractGenerationExtension / IServiceContractGenerationExtension)
1.3.3. IPolicy[Import/Export]Extension
1.4. Configuration
1.4.1. BehaviorExtensionElement
1.4.2. BindingElementExtensionElement / StandardBindingElement / StandardBindingCollectionElement
1.5. Web Hosting
1.5.1. ServiceHostFactory
1.6. WCF REST (3.5 / 4.0 model)
1.6.1. QueryStringConverter
1.6.2. Extending WebHttpBehavior
1.7. Others
1.7.1. Extensible objects: IExtensibleObject<T> and IExtension<T>
2. Channel extensibility
2.1. Protocol channels (client)
2.2. Protocol channels (server)
2.3. Message encoders
2.4. Transport channels
2.4.1. Request transport channels - part 1 (synchronous path)
2.4.2. Request transport channels - part 2 (interaction with runtime extensions)
2.4.3. Request transport channels - part 3 (asynchronous path)
2.4.4. Reply transport channels
2.4.5. Duplex transport channels
3. Serialization extensibility
3.1. Serialization callbacks (On[Ser/Deser]ializ[ing/ed])
3.2. IDataContractSurrogate
3.3. DataContractResolver
3.4. IExtensibleDataObject / IDeserializationCallback / IObjectReference
4. Miscellaneous extensibility scenarios
4.1. Hooking into the tracing mechanism
4.2. Custom serialization in Silverlight 4
4.3. Extensibility in Windows Phone / Silverlight 3
4.4. WCF RIA Services
5. Wrapping up

Tuesday, February 21, 2012

NHibernate Mapping-by-code series

With the introduction of NHibernate 3.2, a new mapping feature was introduced: mapping-by-code. Conceptually this is similar to Fluent NHibernate and the Code First mapping in Entity Framework.  I really liked Fluent NHibernate but I had a hard time getting used to the out-of-the-box mapping-by-code feature. It' is not documented at all so I was really happy when I discovered this blog series by Adam Bar. As he says it himself it’s probably the only complete guide to mapping-by-code on the web so far. (I only found the blog of Fabio Maulo as another resource)

Here is the full table of contents of the mapping-by-code series.

  1. First impressions
  2. Naming convention resembling Fluent
  3. Property
  4. Component
  5. ManyToOne
  6. inheritance
  7. dynamic component
  8. Set and Bag
  9. OneToMany and other collection-based relation types
  10. concurrency
  11. OneToOne
  12. Join
  13. Any
  14. List, Array, IdBag
  15. Map
  16. Id, NaturalId
  17. composite identifiers
  18. entity-level mappings

Thanks Adam!

Monday, February 20, 2012

Essential JavaScript Design Patterns for Beginners

Addy Osmani has released a free ebook about JavaScript Design Patterns. Notice that the focus is on beginners.

This book walks through the classical Gang of Four Design patterns(and some others…) but uses JavaScript for all the samples through the book. Even if you already know these Design Patterns by head, I can still recommend the reading because it helps to improve your JavaScript skills(It certainly helped me!).

I especially liked the second part of the book where samples are shown based on jQuery.

The content outline:

Friday, February 17, 2012

C# 5: Caller Info Attributes

One of the new features that will be available in C# 5 are the Caller Info Attributes.
So what is this animal? If you are/were a C++ developer you probably know the __FILE__ and __LINE__ macros, which expand when compiled to produce a string containing the name of the current source file, and the current line, respectively. Of course C# 5.0 doesn’t support macro’s but the C# team used a different trick to introduce the CallerFilePath, CallerLineNumber and CallerMemberName attributes.
A simple sample:
public static class Trace
{
 public static void WriteLine(string message,
  [CallerFilePath] string file = "",
  [CallerLineNumber] in line = 0,
  [CallerMemberName] string member = "")
 {
  var s = string.Format("{0}:{1} - {2}: {3}", file, line, member, message);

  Console.WriteLine(s);
 }
}
 

If you call the WriteLine method only specifying the message property the compiler would automatically fill out the optional parameters in the WriteLine method with details of where you made the call from.

How can this be useful?

Think about the INotifyPropertyChanged which typically requires the use of magic strings.  Instead of relying on expression trees to get some type safety, we’ll be able to do the following:

protected void RaisePropertyChanged([CallerMemberName] string member = "")
{
    var propertyChanged= PropertyChanged;
    if(propertyChanged != null)
    {
        propertyChanged(new PropertyChangedEventArgs(this, member));
    }
}

and now when you call this method from a property setter, leaving out the optional parameter:

public string ProductName
{
    get
    {
        return _productName;
    }
    set
    {
        _productName=value;
        RaisePropertyChanged();
    }
}

the compiler will fill out the parameter for you, passing “ProductName” to the RaisePropertyChanged method(at least that’s what I hope that it will do, as the feature is not available yet in the current Developer Preview).

Goodbye magic strings!

Thursday, February 16, 2012

Grant IIS 7.5 access to a certificate in certificate store

You have build this nicely secured application in ASP.NET but now you want to deploy it to IIS. Suddenly the application no longer works because you are calling some secure backend services using a certificate in your certificate store. However your IIS application pool user cannot access the certificate.

How can we give IIS 7.5 the correct permissions to read a certificate from the certificate store?
  • Open the certificates MMC.
    • Open MMC
    • Click File –> Add/Remove Snap-in…
    • Choose Certificates and click Add
    • Select Computer Account and click Finish
  • Check if the certificate is available in the "Local Computer\Personal" cert store.
  • Check if the private key of the certificate is marked as exportable.
  • Right click on the certificate and choose "All Tasks --> Manage Private Keys" and "IIS AppPool\DefaultAppPool" or other user or app pool account that the IIS 7.5 app pool is using (ApplicationPoolIdentity).

That’s it!

Wednesday, February 15, 2012

Windows Phone 7: 31 days of Mango e-book

Jeff Blankenburg released, with the help of a lot of other authors, the 31 Days of Mango e-book format for Kindle. If you would like to read all of these articles on-the-go, while supporting the developers that wrote them, they are now available for in the Nook and Kindle stores!

Of course, if you are short of money, you can still read the online version

Cover

Tuesday, February 14, 2012

TF26204: The account you entered is not recognized

While trying to import a work item definition into a team project I received the following error message:
“TF26204: The account you entered is not recognized. Contact your Team Foundation Server administrator to add your account.”
I found out that the issue was causes by a fault in the AssignedTo field assignment. In the rules we added an allowedvalues rule to filter the list to the project contributors. The following xml was used in the Work Item Type Definition:
<FieldDefinition reportable="dimension" refname="System.AssignedTo" name="Assigned To" syncnamechanges="true" type="String">
  <ALLOWEDVALUES filteritems="excludegroups">
    <LISTITEM value="&quot;[Project]\Contributors&quot;" />
  </ALLOWEDVALUES>
  <HELPTEXT>The person currently working on this task</HELPTEXT>
</FieldDefinition>


image


Did you notice the double quotes in the value. This caused TFS to misinterpret the value and of course “[Project]\Contributors” is a non existing user. Removing the quotes solved the issue:

 
<FieldDefinition reportable="dimension" refname="System.AssignedTo" name="Assigned To" syncnamechanges="true" type="String">
  <ALLOWEDVALUES filteritems="excludegroups">
    <LISTITEM value="[Project]\Contributors" />
  </ALLOWEDVALUES>
  <HELPTEXT>The person currently working on this task</HELPTEXT>
</FieldDefinition>

Monday, February 13, 2012

Farewell WCF Web API… Welcome ASP.NET Web API

***Important remark: this is all unofficial information I have found while browsing through the WCF Web API discussion board. So feel free to leave a comment if some of the things I’ve found are not correct.***
WCF Web API will die soon. But in it’s ashes a new API is born, this time based on ASP.NET instead of WCF.
I found the following information about this:
  • Web API will be coming late February as part of the ASP.NET MVC 4 beta.
  • RTM in Q3 2012
  • Will support ASP.NET 4.0, including a HttpClient implementation
  • ASP.NET Web API is not limited to only MVC4, possible to host in WebForms for example.
  • ASP.NET Web API is a separate assembly with no dependency on system.web.mvc.dll
  • Deep integration with MVC routing to identify resources, including default values and constraints
  • Web API uses MapHttpRoute() with a routeTemplate ("api/{controller}/{id}"), very similar to the MVC .MapRoute.
    • UriTemplates not attributes on methods anymore.
    • Discovers actions based on method name (Get, Post etc), but possible to override with attributes.
  • HttpOperationHandler replaced by MVC ActionFilters.
  • Authorization filter attributes, just like MVC
  • Exception filters
  • All stack is async Task based.
  • Web API classes inherit from ApiController base class
    • Instantiated per request, stateless
  • HTTP methods are now like MVC actions
  • Official site will probably be (not working at the moment): http://asp.net/web-api
  • HttpResponseException and HttpResponseMessage/Request still there
  • MVC-like model binding to input parameters
  • Model binding validation using filters and data annotations!
  • Message body bound to types using MediaTypeFormatters
  • Content negotiation supported based on Accept header
  • No static context objects
  • HttpRequestMessage.Properties is still the way to keep request context
  • Out-of-the box IOC integration through DependencyResolver
  • OData supported simply by returning IQueryable<T> from actions, the rest is automatic.
  • Web API/MVC ships with dynamic JsonObject types
  • Supports hosting in IIS or self-hosting.
  • Only a tiny bit of WCF left in there(in the self-host client).
  • Supports JSON.NET out of the box.

Team Explorer Everywhere without Eclipse

If you are a Linux/Unix/Mac user and you want to connect to Team Foundation Server, you can use the Team Explorer Everywhere(TEE) client, an Eclipse based plugin.

I got a question from some customers wanted to use the plug-in to manage TFS applications in a stand-alone fashion even though they were not developing in an Eclipse based IDE.

You have 2 options in this case:

  • Option 1: Use the command line tools.
  • Option 2: If you prefer a visual experience, you can install the plug-in into the Eclipse Platform Runtime Binary (a cut down version of Eclipse without all the language tools for code editing etc).

Remark: Don’t forget that a SP1 was released for TEE, so use the version available here.

Team Explorer Everywhere

Friday, February 10, 2012

Team Foundation Server 2010: Enable checkin policy through code

Just a quick code snippet if you want to enable check-in policies through code:

var projectCollectionUri = new Uri("http://tfs2010:8080/tfs/MyCollection");
var projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(projectCollectionUri, new UICredentialsProvider())
projectCollection.EnsureAuthenticated();

var vcs = projectCollection.GetService<VersionControlServer>();

var teamProject = vcs.GetTeamProject("SomeTeamProject");
var workItemPolicy=new WorkItemPolicy();

foreach (PolicyType policyType in Workstation.Current.InstalledPolicyTypes)
{
if (policyType.Name == workItemPolicy.Type)
{
teamProject.SetCheckinPolicies(new PolicyEnvelope[] { new PolicyEnvelope(workItemPolicy, policyType) });
break;
}
}



In this sample I’m enabling the WorkItems policy(which is part of the Microsoft.TeamFoundation.VersionControl.Controls assembly).

Thursday, February 9, 2012

SQL Server Reporting Services error: The report parameter has a DefaultValue or a ValidValue that depends on the report parameter . Forward dependencies are not valid.

For an application we are using SQL Server Reporting Services. However we had issues with one report. In this report, we have 2 parameters, e.g. OrderId & CustomerId. The value for CustomerId is calculated by executing a first query using the OrderId parameter. This is something that can be done easily in reporting services. However after configuring the parameters, compilation failed with the following error message:

[rsInvalidReportParameterDependency] The report parameter ‘CustomerId’ has a DefaultValue or a ValidValue that depends on the report parameter “OrderId”. Forward dependencies are not valid.

 

Build complete -- 1 errors, 0 warnings

It sounds like a parameter can not depend on another parameter but why did they provided this functionality? Obviously there must be something else that we did wrong.

After trying almost everything you could imagine, we finally discovered that the order of the parameters are wrong. In the parameters list of your SQL Server Report it is important that you place the parameters in the correct order(!).

So after putting the OrderId first and the CustomerId second, everything worked…Verwarde emoticon

Wednesday, February 8, 2012

Effective code reviews: ‘Buddy reviews’

Always looking for ways to improve the quality of our code, one thing I can recommend is the introduction of ‘buddy reviews’. You probably know the normal code review where maybe once a month, a technical lead or architect has a look at your code. Of course you have already moved on to another part of the code, so it’s way too late to fix all the detected issues (with an increasing technical debt as a consequence). 

code_review

So let’s introduce the buddy review. It consists of meeting up with another team member informally (ideally before you check-in your code) and having a quick glance (5 - 10 mins) at each other's code at your desk or their's. This approach has the following benefits above the ‘formal’ code reviews:

  1. Problems are caught very early.
  2. You are always up to speed as to what is going on.
  3. Reviews are always very short because you are only looking at new code since the last catch up .
  4. Because the setting is informal - there is no nervous tension.
  5. They're fun! You can exchange ideas - regularly.

Go and try this with your team! You’ll not regret it.

Tuesday, February 7, 2012

event.srcElement vs event.Target

Web development is fun until you stumble over some browser specific issues. One bug we got last week was a script that worked in IE but not in Firefox:
that.selected=function(e){
 var source=e.srcElement;
 //Some extra code...
}


This one is actually a bug in IE, we are using srcElement which is an Internet Explorer proprietary element. The official property is named target, so this fixed the code:
that.selected=function(e){
 var source=e.target;
 //Some extra code...
}

Monday, February 6, 2012

ASP.NET MVC: Binding Arrays

The modelbinder in ASP.NET MVC is a piece of black art, converting your inputs to a nice strongly typed model. However, when binding to arrays, the DefaultModelbinder has an irritating bug. If the array is already instantiate in the model, the model binder will attempt to call .Clear() and then .Add() on the array. However arrays are fixed size lists. As a result, calling .Clear() throws a NotSupportedException as shown in the following stack trace:
System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.--System.NotSupportedException : Collection is read-only.at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, ref SignatureStruct sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
To resolve this, you can use the following model binder. It simply forces the model to null before invoking the default binder, effectively sidestepping the problem.
public class ArrayModelBinder : DefaultModelBinder
{
 public override object BindModel(
            ControllerContext controllerContext, 
            ModelBindingContext bindingContext)
 {
  var originalMetadata = bindingContext.ModelMetadata;
 
  bindingContext.ModelMetadata = new ModelMetadata(
   ModelMetadataProviders.Current,
   originalMetadata.ContainerType,
   () => null,  //Forces model to null
   originalMetadata.ModelType,
   originalMetadata.PropertyName
   );
 
  return base.BindModel(controllerContext, bindingContext);
 }
}
UPDATE:I noticed that the problem is fixed in .NET 4.5 with the introduction of the ArrayModelBinder.

Friday, February 3, 2012

Visual Studio 2010: Configure the Parallel Execution of Unit Tests

Today almost every machine has multiple CPU’s or a CPU with multiple cores. Unfortunately Visual Studio 2010 is not using most of this power. However you can change the Visual Studio 2010 configuration to run Unit Tests  in parallel.
How To Enable Parallel Execution of Unit Tests
1. Create a new Test Project in Visual Studio 2010
2. Right click on “Local.testsettings” and click “Open With”, choose “Xml (Text) Editor” and hit OK.
3. Expand the Execution Tag and add an additional attribute called – parallelTestCount:
<TestSettings>
 <Description>These are default test settings for a local test run.</Description>
 <Deployment enabled="false" />
 <Execution parallelTestCount="3">
  ...
 </Execution>
</TestSettings>


You can specify the following numbers:
  • 0 = Auto configure: Visual Studio will try to optimize based on the CPU and core count.
  • Another number=Define the number of tests to run in parallel yourself.

Thursday, February 2, 2012

JavaScript and Css Bundling and Minification

If you can’t wait until Microsoft releases ASP.NET MVC 4 (which includes bundling and minification out-of-the-box), I have good news for you. Microsoft released early bits of this feature in the Microsoft.Web.Optimization NuGet Package. This package adds support for easy minification and bundling of text-based (js, css, etc) files to your ASP.NET (MVC) web applications. The tool works by adding routes and rules to how and what it should bundle and minify.
How to use it?
Download and install the Microsoft.Web.Optimization package using NuGet.
image
After installing the package, add the following code to Application_Start in Global.asax
BundleTable.Bundles.EnableDefaultBundles();

BundleTable.Bundles.ResolveBundleUrl() creates an hash based on the combined files. This ensures that while combining and minifying css you're not creating caching issues that often occur when doing these kinds of optimizations.

Now you can replace your existing css with this:
<link href="@BundleTable.Bundles.ResolveBundleUrl("~/Content/css")" rel="stylesheet" type="text/css" />


This will result in one file with minified css being sent to the client.
image

This works thanks to the  EnableDefaultBundles(). Calling this method add routes for /css and /js. The default rule look for all .css files in the directory and combines and minifies them before sending the result to the client. The exact same thing also works with ~/Scripts/js which would combine and minify all our .js files in the ~/Scripts directory.

Wednesday, February 1, 2012

ASP.NET MVC: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.

When loading a big JsonResult from the server, the request fails with the following error message:

“InvalidOperationException:Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.”

Thanks to this descriptive error message, its quiet clear what’s happening. The size of the JSON object exceeds the maxJsonLength value of the JavaScriptSerializer class that’s used behind the scenes.

But how can we change this value?

You cannot access this property directly through the JsonResult. Instead you can create your own result:

public class ExtendedJsonResult : ActionResult
{
public ExtendedJsonResult()
{
this.JsonRequestBehavior = JsonRequestBehavior.DenyGet;
this.MaxJsonLength=Int.MaxValue;
}

public override void ExecuteResult(ControllerContext context)
{
if (context == null)
{
throw new ArgumentNullException("context");
}
if ((this.JsonRequestBehavior == JsonRequestBehavior.DenyGet) && string.Equals(context.HttpContext.Request.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase))
{
throw new InvalidOperationException(MvcResources.JsonRequest_GetNotAllowed);
}
HttpResponseBase response = context.HttpContext.Response;
if (!string.IsNullOrEmpty(this.ContentType))
{
response.ContentType = this.ContentType;
}
else
{
response.ContentType = "application/json";
}
if (this.ContentEncoding != null)
{
response.ContentEncoding = this.ContentEncoding;
}
if (this.Data != null)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
serializer.MaxJsonLength=this.MaxJsonLength;
response.Write(serializer.Serialize(this.Data));
}
}

public Encoding ContentEncoding { get; set; }

public string ContentType { get; set; }

public object Data { get; set; }

public JsonRequestBehavior JsonRequestBehavior { get; set; }

public int MaxJsonLength{get;set;}
}