Friday, 15 August 2014

c# - mvc client access without browser or view -



c# - mvc client access without browser or view -

i have mvc4 c# application want allow client access through code (no browser or view). client send user id used record , 3 fields returned. both incoming , outgoing info sensitive info need solution secure. application running on site ssl (https), protect me json hijacking if utilize json solution 2 answers have suggested?

public actionresult inaction(string id) { // code retrieve record , homecoming 3 fields field1, field2, field3 homecoming (what go here?) }

can utilize controller action handle this? need total blown webservice this, if links mvc tutorials helpful?

the client works in asp (webforms) , talking responder page key value pairs, how equivalent in mvc.

any help on getting me going appreciated.

thank you

update: i’ve marked brett’s json suggestion answer. returning string (not array) , entire transaction taking place on ssl connection believe possibility of json hijacking not issue.

string response = field1 + "," + field2 + "," + field3; homecoming json(response), jsonrequestbehavior.allowget; }

if i'm mistaken on please allow me know.

as nikeaa mentions, create action within controller returns jsonresult

public jsonresult inaction(string id) { // object repository var repository = new objectrepository(); var returnobj = repository.getobject(id); homecoming json(returnobj, jsonrequestbehavior.allowget); }

you need specify jsonrequestbehaviour.allowget override default .denyget. opens security vulnerability when returning json request though. see stackoverflow reply details.

c# asp.net-mvc web-services asp.net-mvc-4

No comments:

Post a Comment