kheya
kheya

Reputation: 7631

Why MVC is generating route with weird parameter?

I am getting url routes like this in firebug:

http://<host>/user/bob/GetFollowers?pageno=2&_=1395084415411

Why the url has &_=1395084415411 at the end? I checked the ajax call, I am not adding\passing the _=1395084415411 parameter

This is my route configuration:

context.MapRoute(
  "Action",
  "user/{id}/{action}",
   new { action = "index", controller = "MyController" },
   new string[] { "App.Controllers" }
   );

Here is the controller:

[HttpGet]
public ActionResult GetFollowers(string id, int pageno){
}

EDIT: I am using a plugin to make all ajax request. Here is the part that sends the call:

$.ajax({
                url: this.url,
                cache: false,
                type: this.method,
                data: (this.method.toUpperCase() === "GET") ? this.params.toObject() : JSON.stringify(this.params.toObject()),
                dataType: "json",
                contentType: 'application/json',
                success: Function.reference(this, this.success),
                error: Function.reference(this, this.error),
                async: this.getAsync()
            });

Upvotes: 0

Views: 114

Answers (2)

Van
Van

Reputation: 1387

the additional stuff in your url is there to make your request unique. if you set cache:true in your ajax object, you should no longer see that extra bit.

Upvotes: 1

DeeDub
DeeDub

Reputation: 1662

The additional '&_=1395084415411' is going to be a function callback for JSONP. It should not interfere with your actual data sent/received. You may be making the call with a dataType: 'jsonp'.

Upvotes: 0

Related Questions