URL-Encoded post parameters don't Bind to model

Posted by Steven Klein on Stack Overflow See other posts from Stack Overflow or by Steven Klein
Published on 2013-05-02T17:24:56Z Indexed on 2013/06/27 22:21 UTC
Read the original article Hit count: 220

Filed under:
|
|

I have the 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 the following method:

[HttpPost]
 public HttpResponseMessage GetQuickbooksOFXService(Internal.ReportRequest Request){       
     return GetQuickbooksOFXService(Request.UserName, 
         Request.Password, Request.StartTime, Request.EndTime, Request.FileName);
 }

My webform looks like 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 get into the GetQuickbooksOFXService function but my model has all nulls in it instead something useful. Am I doing something wrong?

© Stack Overflow or respective owner

Related posts about c#

Related posts about asp.net-mvc-4