.net - Url.Action not working as expected -
i'm using same view in 2 action on same controller. first view relaunches second, in sec round, url.action
automatically inserts url parameter
this code:
function doredirect() { debugger; var info = { }; data.modules = dict; data.pages = dictpage; $.ajax({ type: "post", url: '@url.action("reordermodules")' + '/' + model.phasedocumentid, contenttype: "application/json; charset=utf-8", data: json.stringify(data) , datatype: "json", async: false, success: function(msg) { ////debugger; window.location.href = '@url.action("updatemodelview")' + '/' + model.phasedocumentid; } }); }
on first step @url.action("updatemodelview")
right on sec step value right path + id passed on first step, have error because concatenate 2 times same id
any ideas?
update controller code:
public actionresult updatemodelview(guid id) { var model = srvdispatcher.phasedocumentservice.getphasedocumentbyid(id.tostring()); ..... viewbag.modelnohtml = model; homecoming view("createphase2", model); }
first time client side code :
function doredirect() { debugger; var info = { }; data.modules = dict; data.pages = dictpage; $.ajax({ type: "post", url: '/phasedocuments/reordermodules' + '/' + model.phasedocumentid, contenttype: "application/json; charset=utf-8", data: json.stringify(data) , datatype: "json", async: false, success: function(msg) { ////debugger; window.location.href = '/phasedocuments/updatemodelview' + '/' + model.phasedocumentid; } });
second time client-code :
function doredirect() { debugger; var info = { }; data.modules = dict; data.pages = dictpage; $.ajax({ type: "post", url: '/phasedocuments/reordermodules' + '/' + model.phasedocumentid, contenttype: "application/json; charset=utf-8", data: json.stringify(data) , datatype: "json", async: false, success: function(msg) { ////debugger; window.location.href = '/phasedocuments/updatemodelview/60cfe283-dcd6-47db-9f85-3cf662cd5ccf' + '/' + model.phasedocumentid; } });
the model var json version of controller model
var model = @html.raw(jsonconvert.serializeobject(modelnohtml, formatting.indented, new jsonserializersettings() { referenceloophandling = newtonsoft.json.referenceloophandling.ignore }));
solution solution on similar question
solution
.net asp.net-mvc json.net razor-2
No comments:
Post a Comment