json - Appending url direct in mvc controller -


having problem since deployed app. lot of pages aren't loading because if have either configured wrong created wrong.

i have line in controllers:

return json(new { ok = true, newurl = (@url.content("~/maintenance/_titledetails")) }, "application/json", jsonrequestbehavior.denyget); 

(based use in view works. loads url as

 http://ip..../~/maintenance_titledetails  

and such failing because there should app name ~ is.

this works view put razor specific.

having same issue html generated links also. can point me in right direction please best way of doing this?

edit

have tried capture context in c# failed also.

system.web.httpcontext curcontext = system.web.httpcontext.current;              return json(new { ok = true, newurl = (curcontext + ("/maintenance/_titledetails")) }, "application/json", jsonrequestbehavior.denyget); 

http://162.168.0.1/system.web.httpcontext/maintenance/_titledetails 404 (not found)

edit 2 works with

string baseurl = system.web.httpcontext.current.request.applicationpath.trimend('/');              return json(new { ok = true, newurl = (baseurl + ("/maintenance/_titledetails")) }, "application/json", jsonrequestbehavior.denyget); 

but wondering if there better way of doing rather having in every controller action?


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -