Getting Ajax calls to work with MVC4

January 31, 2013 at 4:18 PMMadestro

I recently started working with MVC4. After (literally) cutting and pasting code from some other application I had worked on which used MVC3, I found my Ajax calls where no longer working. 

It took me about three hours of research to figure out what the issue was.

The JQuery libraries that are used for Ajax calls are loaded in a different manner now. In the past, you would include them one by one in your _layout file. With the new version, you need to introduce the right "bundle". 

If you look at the code generated by the VS template, you will see two calls that load stuff for you:

@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")

What you need to do is add the following two lines of code in order to load the JQuery includes:

@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jqueryval")

What's happening under the scenes is that there is now a new Bundle and Minification Framework in place. If you look at your App_Start folder, you will notice a file called BundleConfig.cs. This file contains bundle definitions that are used to load resources. You can read more about it here.

The bundle in question here is defined as follows:

bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                        "~/Scripts/jquery.unobtrusive*",
                        "~/Scripts/jquery.validate*"));
 

Once these two files are loaded, your Ajax calls should start working again.

Hopefully this post will save you some Google time... you can find the source that solved my issue here.

Posted in: ASP.NET MVC

Tags:

SEO Keyword Madness... No More

January 28, 2013 at 1:44 PMMadestro

Back in April, Google updated their algorithms so that pages overloaded with relevant keywords actually rank lower. Now they are officially warning against this practice in their guidelines.

On top of that, encrypted search (when you get the "not provided" keyword entry in the reports) has essentially made keyword reporting unreliable.

If you are interested in the details, you can read the full article from Starpoint Marketing here.

That's right. Finally, no more meaningless garbage designed to generate more hits!

More meaningful content, more elegant content. That's the way it should be.

Posted in: SEO

Tags: