RSS

ASP.Net MVC 4 Bundles Ignore List

.min JavaScript Files

It all started when I tried to bundle a .min JavaScript file in my ASP.Net MVC 4 application. MVC just completely ignore any .min files I have in BundleConfig.cs.

Obviously, it doesn’t work. OK, it’s not so obvious when it happened to me.

Ignore List

Turn out, ASP.Net MVC 4 Bundles has ignore list. You guess it, the .min extension is included in the ignore list. To override the ignore list:

public static void SetIgnorePatterns(IgnoreList ignoreList)
{
    if (ignoreList == null)
        throw new ArgumentNullException("ignoreList");

    ignoreList.Ignore("*.intellisense.js");
    ignoreList.Ignore("*-vsdoc.js");
    ignoreList.Ignore("*.debug.js", OptimizationMode.WhenEnabled);
    //ignoreList.Ignore("*.min.js", OptimizationMode.WhenDisabled);
    ignoreList.Ignore("*.min.css", OptimizationMode.WhenDisabled);
}

public static void RegisterBundles(BundleCollection bundles)
{
    bundles.IgnoreList.Clear();
    SetIgnorePatterns(bundles.IgnoreList);

    // Continue with your code ...
}

That’s it, the .min JavaScript file will now be included in bundling.

Alternatively, you can also rename the JavaScript to remove its .min extension to be included in bundling process. This approach doesn’t require modification of bundle’s Ignore List.

While we are on the subject, it’s important to note that Bundle and Minification are different process. ASP.Net site explains it as:

Bundling

Bundling is a new feature in ASP.NET 4.5 that makes it easy to combine or bundle multiple files into a single file. You can create CSS, JavaScript and other bundles. Fewer files means fewer HTTP requests and that can improve first page load  performance.

Minification

Minification performs a variety of different code optimizations to scripts or css, such as removing unnecessary white space and comments and shortening variable names to one character. Consider the following JavaScript function.

Source: MVC 4 Bundling and Minification

 
Leave a comment

Posted by on April 18, 2014 in Programming

 

Tags: ,

What is Prototype?

In JavaScript, objects also have one additional attribute: a pointer to another object. We call this pointer the object’s prototype.

Prototype allows you to create inheritance in JavaScript objects.

var man = Object.create(null);
defineProperty(man, 'sex', "male");

var yehuda = Object.create(man);
defineProperty(yehuda, 'firstName', "Yehuda");
defineProperty(yehuda, 'lastName', "Katz");

yehuda.sex       // "male"
yehuda.firstName // "Yehuda"
yehuda.lastName  // "Katz"

Object.getPrototypeOf(yehuda) // returns the man object

Read more: Yehuda Katz’s Understanding Prototype in JavaScript

 
Leave a comment

Posted by on March 21, 2014 in Architecture

 

Tags: ,

What is CLR?

The Common Language Runtime (CLR) is the virtual machine component of Microsoft’s .NET framework and is responsible for managing the execution of .NET programs.

A language like C# requires the .NET Common Language Runtime (CLR) to execute. Essentially, as an application that is written in C# executes, the CLR is managing memory, performing garbage collection, handling exceptions, and providing many more services that you, as a developer, don’t have to write code for. The C# compiler produces Intermediate Language (IL) , rather than machine language, and the CLR understands IL. When the CLR sees the IL, it Just-In-Time (JIT) compiles it, method by method, into compiled machine code in memory and executes it. The CLR manages the code as it executes.

Read more: Common Language Runtime – Wikipedia

 
Leave a comment

Posted by on March 21, 2014 in Architecture

 

Tags: ,

ASP.NET Web API and OData’s Verbose JSON

OData v3 and Verbose JSON

Whenever you work with OData in ASP.NET Web API, the return result will be JSON format. It’s noteworthy to know that by default Web API will return new OData JSON format specified in OData version 3. For older OData, the JSON format is different. It has more ‘unnecessary’ placeholders. This old OData JSON is also referred as ‘Verbose JSON’. In short, there are two types of OData JSON:

  • OData v3 has new JSON format
  • Verbose JSON is used in older OData versions.

ASP.NET Web API (.Net 4.5) and Verbose JSON

As mentioned before, by default Web API will return new OData JSON.

To change this behavior, you can request Web API to return old OData JSON format by specifying ‘odata=verbose’ in Accept header. Below is the sample of jQuery Ajax call specifying verbose JSON:

$.ajax({
    url: "/api/Products",
    dataType: "json",
    accepts: { json: "application/json;odata=verbose" }
}).done(function() {
    // do work ...
});

How it Looks Like?

For the curious:

Verbose JSON

{
    "d" : {
        "results": [
            {
                "__metadata": {
                    "uri": "http://demos/Orders(10248)",
                    "type": "SampleModel.Order"
                },
                "ProductId": 10248,
                "Name": "Vgnon"
            }
        ],
        "__count": "1"
    }
}

OData v3 (and above) JSON

{
    "odata.metadata":"http://localhost:43111/api/$metadata#Products",
    "odata.count":"1",
    "value":
    [
        {
            "ProductId":2,
            "CreatedDate":"2013-06-10T23:53:26",
            "CreatedBy":0,"Name":"Camera"
        }
    ]
}
 
Leave a comment

Posted by on October 7, 2013 in Programming

 

Tags: , ,

Compare Two URL Strings

URL String Compare

What is the best approach to compare two URLs and determine if they are the same or not?

For example:
http://stack247.wordpress.com and stack247.wordpress.com are the same URL.
https://stack247.wordpress.com and stack247.wordpress.com are the same URL.
http://stack247.wordpress.com/tag/interview-question/ and stack247.wordpress.com/tag are NOT the same URL.

 
Leave a comment

Posted by on July 31, 2013 in TechChallenge

 

Tags: , ,

Introducing technophile.co

Stay Up-to-date With Web Technologies

Home Slide

We are launching technophile.co today! It’s a new way to stay up-to-date with web technologies. We are adding more and more technologies to our library everyday, so check it out!

What is it?

tech·no·phile (noun) \ˈtek-nə-ˌfī(-ə)l\

One who has a love of or enthusiasm for technology, especially computers and high technology.

Technophile helps developers stay up-to-date with web technologies. That is, framework, library, plug-in or language of your technology stack.

It’s a directory of web technologies that you can browse and search. Technophile is still in Beta but we are actively developing new features to provide better user experience.

The Problem We’re Trying to Solve

When it comes to web technologies, developers are facing with choices far more than our needs.

For front-end / client-side alone, there are countless JavaScript frameworks available in open source projects. A developer is also expected to master few server-side technologies, be it database, back-end, service layer and presentation. To top it all, even in our own technology stack, .Net, Java or JavaScript, there are enormous choices of framework, library and plug-in. With this excessive alternatives in web technologies, it’s next to impossible to keep up with all of them.

Then, there is a decision to be made.

We all hope to make a good decision if not a smart one. Reality is, with choices far more than we can grasp, it becomes a immensely difficult decision. It’s a decision to be made, nonetheless.

In short, we want to equip developers with knowledge of vastly-available web technologies out there to help them make a smart decision when it comes to choosing web technologies.

 
Leave a comment

Posted by on July 29, 2013 in General

 

Denormalization

The process of attempting to optimize the read performance of a database by adding redundant data or by grouping data.

For online analytical processing (OLAP – primarily read operation) databases, redundant or “denormalized” data may facilitate business intelligence applications. In many cases, the need for denormalization has waned as computers and RDBMS software have become more powerful, but since data volumes have generally increased along with hardware and software performance, OLAP databases often still use denormalized schemas.

Source: Wikipedia: Denormalization

 
Leave a comment

Posted by on July 29, 2013 in Dictionary

 

Tags: ,

 
Follow

Get every new post delivered to your Inbox.

Join 35 other followers

%d bloggers like this: