Replace JavaScript serializer in Kendo controls with NewtonSoft


I have been doing code optimization for an ASP MVC 5 application that uses the Telerik Kendo controls. Some of the search results may return 7000 records in this project. After I had replaced the serializer, it took 30% less time to load the search results page.

 

The ASP MVC Helpers for Kendo controls by default use the System.Web.Script.Serialization.JavaScriptSerializer which is slow compared to the NewtonSoft Json serializer. Telerik made it easy to replace the default serializer.

Steps:

  • Created a class that implements IJavaScriptSerializer and implement the Serialize method.
    public class CustomKendoJsonSerializer : IJavaScriptSerializer
    {
       public string Serialize(object value)
       {
          return JsonConvert.SerializeObject(value); //use the serializer you want  here
       }
     }
    
  • Create a class that implements JavaScriptInitializer and implement the CreateSerializer method
    
    public class CustomKendoInitializer : JavaScriptInitializer
    
    {
    
    public override IJavaScriptSerializer CreateSerializer()
    
    {
    
    return new CustomKendoJsonSerializer ();
    
    }
    
    }
    
    
  • In the Application_Start event in the Global.asax file, register the new serializer
Kendo.Mvc.Infrastructure.DI.Current.Register<IJavaScriptInitializer>(() => new CustomKendoInitializer());
Categories: .NET, asp.net, C# Tags: , ,

ASP MVC 5: ViewBag does not exist in the current context


After upgrading one of my client’s applications from ASP MVC 4 to ASP MVC 5, We had designers errors related to Html Helpers and ViewBag in cshtml pages.

To fix those issues make sure you do the following:
Install Asp.NET Web Helpers Library from Nuget
Open the Web.config of the project and update the bindings if they haven’t been updated when installing the Nuget packages for example

<dependentAssembly>
<assemblyIdentity name=”System.Web.Mvc” publicKeyToken=”31bf3856ad364e35″ />
<bindingRedirect oldVersion=”0.0.0.0-5.2.2.0″ newVersion=”5.2.2.0” />
</dependentAssembly>

 

Find “webpages:Version” in the appsettings and update it to version 3.0.0.0. My web.config had

<add key=”webpages:Version” value=”2.0.0.0″ />

and I updated it to

<add key=”webpages:Version” value=”3.0.0.0″ />

Restart Visual Studio and rebuild. You may have to delete the bin folder for your project

 

Categories: asp.net Tags: ,

Load Testing: Context parameter ‘$HIDDEN1.__RequestVerificationToken’ not found in test context


I was doing load testing using Visual Studio 2013 Ultimate for one of the applications I was working on and I noticed the following error when I try to run the recorded load test

Context parameter ‘$HIDDEN1.__RequestVerificationToken’ not found in test context


Scanario

The test scenario was the following:

  • Load home page
  • Click a url on a page
  • Dialog shows up (GET)
  • Select a value from a dropdown on the dialog (POST)
  • Submit

Cause

The tool was trying to use $Hidden1.__RequestVerificationToken from the main page but that variable wasn’t available in the current context.

Resolution

Add a new Extraction Rule, create new variable at the GET request step above the POST request


Assigned the __RequestVerificationToken value in the form to a Context Parameter


In the Post request, change the form post parameter to new token



That specific request was a POST request done using Ajax.

//publish Windows in #Ottawa #pubwin


Finalize your app projects with peers and expert support.

Bring your Windows and Windows Phone apps to a //publish/ coding event and we’ll help you overcome the final blockers to optimizing, completing and publishing your app. https://publishwindows.com/publish

Categories: Uncategorized

Migrate your Visual Studio Online to On-Premises TFS


For a limited time, you can move your Visual Studio Online to on-premises TFS. This feature is turned OFF by default and you need to contact VSOExportSupport@Microsoft.com to turn it on. You also need to upgrade your on-premises TFS to Update 2.  

Microsoft has published step by step article on how to prepare you on-premises environment, export your projects, and import them

http://msdn.microsoft.com/en-us/library/7cb80f0d-0119-4277-82e8-719a8db1796e

 

 

TFS Work Items: Queries more than one state


How can I create a query and filter on more than one state? I had this question last week at a client location. If you are interested in a short answer then the answer is to comma separate the states and you use the In operator. For step by step instructions, read the rest of the article.

In Web Access,

Click on the Work tab

Click on Queries

image

Click on New

Click on New query

image

In this example, I want to select all bugs that are Approved and Committed

From the Work Item Type Value field, select Bug

Select In in the State’s Operator field and Approved,Committed in the Value field.

image

You can click the play button to test your query

Save your query

Categories: TFS Tags: ,

Microsoft Virtual Academy free training


If you are looking for free training, make sure you visit the Microsoft Virtual Academy site at http://www.microsoftvirtualacademy.com/?prid=ca_mvpaa&mtag=MVP5000005 . The website contains many videos related to the Microsoft ecosystem and I am confident that you will enjoy it.

Categories: Uncategorized Tags: ,
Follow

Get every new post delivered to your Inbox.

Join 391 other followers