0
這是我的ApiController代碼。如何通過數據從URL到web Api控制器在asp.net中進行測試mvc
// POST: api/SecurityApi
[ResponseType(typeof(User))]
public IHttpActionResult PostUser([FromUri] GeneralViewModel model)
{
if (model == null)
{
return this.BadRequest(ModelState);
}
if (ModelState.IsValid)
{
User _user = new User();
_user.FullName = model.Security.FullName;
_user.Email = model.Security.Email;
_user.PhoneNo = model.Security.MobileNumber;
_user.Password = model.Security.Password;
_user.RetypePassword = model.Security.RetypePassword;
_user.CityId = model.Security.CityId;
_user.IsUpdate = model.Security.IsUpdate;
_user.StatusId = (byte)Utilities.Status.Active;
_user.EmailConfirmed = false;
_user.Image = "/images/business.png";
_user.CreatedDate = DateTime.Now;
_user.ModifiedDate = DateTime.Now;
_user.CreatedBy = 1;
var userObj = seuritybll.Insert(_user);
//configur Email
EmailModel _m = new EmailModel();
_m.toAddress.Add(model.Security.Email);
_m.Url = "http://www.bedspacefinders.com/Security/CompleteRegistration/" + userObj.ID;
_m.Subject = "Registration Email";
_m.Body = "To complete registration " + "<a href='" + _m.Url + "'>click here.</a> ";
Utilities.Utilities.SendEmail(_m);
return Ok(true);
}
else
{
return this.BadRequest(this.ModelState);
}
//return CreatedAtRoute("DefaultApi", new { id = user.ID }, user);
}
這是我的網址「http://localhost:12865/api/SecurityApi」的API,現在我想通過從URL數據模型放在userRegistration但我不知道如何從URL數據傳遞到apiController首先我用http://localhost:12865/api/SecurityApi「{姓:」?aitzaz 「}」;但不工作的任何人可以幫助我,我如何從URL數據傳遞到apiModel
我用視圖模型的單一模式它的工作正常,但對於ViewModel它不工作,因爲我有ViewModel。 –
很混亂,我不明白你的意思 –