include antiforgerytoken in ajax post ASP.NET MVC

I am having trouble with the AntiForgeryToken with ajax. I’m using ASP.NET MVC 3. I tried the solution in jQuery Ajax calls and the Html.AntiForgeryToken(). Using that solution, the token is now being passed: var data = { … } // with token, key is ‘__RequestVerificationToken’ $.ajax({ type: “POST”, data: data, datatype: “json”, traditional: true, … Read more

Where and how is the _ViewStart.cshtml layout file linked?

Here’s the About.cshtml from the default MVC 3 template: @{ ViewBag.Title = “About Us”; } <h2>About</h2> <p> Put content here. </p> I would expect that a reference to the _ViewStart file would be found in the About.cshtml, but clearly it’s not. I’ve looked in global.asax and web.config, but I can’t find out how the About.cshtml … Read more

Prevent Caching in ASP.NET MVC for specific actions using an attribute

I have an ASP.NET MVC 3 application. This application requests records through jQuery. jQuery calls back to a controller action that returns results in JSON format. I have not been able to prove this, but I’m concerned that my data may be getting cached. I only want the caching to be applied to specific actions, … Read more

Setting Access-Control-Allow-Origin in ASP.Net MVC – simplest possible method

I have a simple actionmethod, that returns some json. It runs on ajax.example.com. I need to access this from another site someothersite.com. If I try to call it, I get the expected…: Origin http://someothersite.com is not allowed by Access-Control-Allow-Origin. I know of two ways to get around this: JSONP and creating a custom HttpHandler to … Read more