Pedro Sobota
Pedro Sobota

Reputation: 1877

$.post being turned into GET

My jQuery $.post calls work ok in my environment. But on production, $.posts are mysteriously being turned into GETs, returning 404.

Dev call: $.post('/Home/Destaques') (call works ok)

Production call: $.post('/Home/Destaques') produces GET /Home/Destaques/ 404 (Not Found)

There are differences between the response headers, namely:

Dev: Server:Microsoft-IIS/7.0 X-AspNet-Version:4.0.30319 X-AspNetMvc-Version:2.0

Production: Server:Microsoft-IIS/6.0 X-AspNet-Version:2.0.50727 (no AspNetMvc header)

Why would a POST become a GET?

Upvotes: 0

Views: 661

Answers (1)

bhuvin
bhuvin

Reputation: 1402

Use @Url.Action while specifying the location. And this is the best example of the issue which occurs and the main reason for Url.Action was introduced in MVC.

EDIT-

Dude See what happens is that we use Url.Action or Url.Content for the same purpose coz the way it is deployed may not be into the root itself.

The Analogy could be mapped to - When you are lost somewhere between the ways to reach a destination , and you ask someone the way to the destination he Answers {Right- Right - left - Right} and you are there. But this might not work if you are not on the same point and follow that way.

So for the server it happens the same. When it was there on the sub site it wasnt able to find the way out since the depth levels were different and as you changed it it started working . So, AFAIK this is the case.

Read Url.Action documentation . An example is given : Scott Guthrie's( MVC GURU) blog

Upvotes: 1

Related Questions