Reduce the json size in MVC 6

In here we removed all default value and null in our json output.

        .Configure<MvcOptions>(options => {
          var jsonOutputFormatter = new JsonOutputFormatter();
          jsonOutputFormatter.SerializerSettings.DefaultValueHandling = DefaultValueHandling.Ignore;
          jsonOutputFormatter.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;

          options.OutputFormatters.Insert(0, jsonOutputFormatter);

MVC Editor Templates

When you start working in the Back Office, we probably would like to overwrite the default behavior of our textbox, calendar, dropdown,geo location etc. By default all it’s all default textbox.

EditorTemplateMvc Continue reading

Typescript Auto Build

When you used VS 2012 it’s won’t auto compile the Typescript to plain Javascript.

Open your project .csproj and paste this below line just below

<Target Name="TypeScriptCompile" BeforeTargets="Build">
 <Message Text="Compiling TypeScript files" />
 <Exec Command="&quot;$(PROGRAMFILES)\Microsoft SDKs\TypeScript\tsc&quot; -target ES5 @(TypeScriptCompile ->'&quot;%(fullpath)&quot;', ' ')" />

.Net Web Developer Should Know?

1. Remove the HTTP Headers

By removing the header “X-Powered-By” you make a save around 29bytes for each requests, another reason as well you doesn’t want exposing stack trace.

Server: Microsoft-IIS/8.5

<httpRuntime targetFramework="4.5.1" enableVersionHeader="false" />

        <clear />
        <remove name="X-Powered-By" />


//In Global put this
MvcHandler.DisableMvcResponseHeader = true;

Continue reading

View Engines MVC

By Default MVC project enable both engines “Web Form” & “Razor”. In some case we doesn’t really care either we using .aspx, .ascx, .cshtml or .vbhtml it’s will just work by itself.


When you enable both of the Engines the performance will be affect, since it’s will figure out the Web Form Engines first then the Razor Engines.

If you exactly know you going to used only Razor Engines, it’s good sign to j^st enable one of the Engines, since it’s will bring performance improvement as well. to enabled Razor Engine simple in your “Global.asax.cs” and put this line of code”

ViewEngines.Engines.Clear(); //remove all view engines
ViewEngines.Engines.Add(new RazorViewEngine()); //We j^st enable the Razor Engine in here.