c# - URL-Encoded post parameters don't Bind to model -
i have following model
namespace clientapi.models { public class internal { public class reportrequest { public datetime starttime; public datetime endtime; public string filename; public string username; public string password; } } }
with following method:
[httppost] public httpresponsemessage getquickbooksofxservice(internal.reportrequest request){ return getquickbooksofxservice(request.username, request.password, request.starttime, request.endtime, request.filename); }
my webform looks this:
<form method="post" action="http://localhost:56772/internal/getquickbooksofxservice" target="_blank"> <input type="text" name="starttime" value="2013-04-03t00:00:00"> <input type="text" name="endtime" value="2013-05-04t00:00:00"> <input type="text" name="filename" value="export_2013-04-03_to_2013-05-03.qbo"> <input type="text" name="username" value="username"> <input type="text" name="password" value="*****"> <input type="submit" value="submit"></form>
my question is:
i getquickbooksofxservice function model has nulls in instead useful. doing wrong?
after doing more testing found not properties in class need public need , set method. after making following started working.
public class reportrequest { public datetime starttime { get; set; } public datetime endtime { get; set; } public string filename { get; set; } public string username { get; set; } public string password { get; set; } }
Comments
Post a Comment