I'm using Asp.Net-Mvc, I have this method in my controller:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult LinkAccount(string site, object id)
{
return this.Json(id);
}
Here's the ajax method that calls it:
$.post("/Account/LinkAccount", { site: "Facebook",
id: FB.Facebook.apiClient.get_session().uid },
function(result) {
alert(result);
}, "json"
);
returning this.Json(id); makes the alert work... it alerts 7128383 (something similar to that).
but if I change this.Json(id)
to this.Json(Conver.ToInt64(id));
the alert does not fire...
Any idea of why I can't convert an object received from an object to a long?
I already know changing the LinkAccount
method to accept a long instead works just fine. It's just I need it as an object because some other sites I'm linking up have strings for id's rather than longs.
UPDATE: I tried running the code on localhost so I could set a breakpoint. First I changed the line return this.Json(Convert.ToInt64(id));
to long idAsLong = Convert.ToInt64(id));
. Here's what the debugger is telling me:
When I hover over id it says: "id | {string[1]}"
and when I press the plus button is shows: "[0] | '7128383'"When I hover over idAsLong, it says: "idAsLong | 0"
Why isn't it converting it properly?