ASP.Net : The requested resource does not support http method 'GET'.
I have hosted my .Net MVC application 4.5 and Asp.Net Web Api 2.0 in Godaddy server. When I try to post my data to database server through Web Api I got an error "The requested resource does not support http method 'GET'." Its work ok when I tried to post my data directly to database without going through Web Api.
1) My MVC method.
[HttpPost]
public ActionResult Create(ItemRegisterViewModel model)
{
var returnObject = new ResponseObject();
returnObject.IsSuccess = true;
if (model.ItemTypeId != 0)
{
if (ModelState.IsValid)
{
var apiClient = new WebApiClient();
returnObject = apiClient.Post("api/Item/Create", model);
if (returnObject != null && returnObject.IsSuccess)
{
TempData["ItemSuccessCreate"] = returnObject.Message;
return RedirectToAction("Create");
}
TempData["ErrorMessage"] = returnObject.Message;
ModelState.AddModelError("", returnObject.Message);
}
else
{
TempData["ErrorMessage"] = returnObject.Message;
ModelState.AddModelError("", "Required fields are required");
}
}
else
{
ModelState.AddModelError("ItemTypeId", "Item Type is required. Select any item type above.");
}
model.ItemTypeList = inventoryController.GetItemTypes();
return View("Create", model);
}
2) My API post method:
[HttpPost]
public HttpResponseMessage Create(ItemRegisterViewModel model)
{
HttpResponseMessage responseMessage = new HttpResponseMessage();
ResponseObject responseObject = new ResponseObject();
UnitOfWork unitOfWork = new UnitOfWork(_database);
responseObject.IsSuccess = true;
if (ModelState.IsValid)
{
try
{
List
Hello Sndp,
Is this more of a general error with Umbraco, than the Umbraco Forms addon product itself?
But to answer your question as you are missing [HttpGet] attribute on the method then ASP.NET MVC will not allow you to do a HTTP Get of that resource, hence the error message it is returning.
ASP.Net : The requested resource does not support http method 'GET'.
I have hosted my .Net MVC application 4.5 and Asp.Net Web Api 2.0 in Godaddy server. When I try to post my data to database server through Web Api I got an error "The requested resource does not support http method 'GET'." Its work ok when I tried to post my data directly to database without going through Web Api.
1) My MVC method.
[HttpPost] public ActionResult Create(ItemRegisterViewModel model) { var returnObject = new ResponseObject(); returnObject.IsSuccess = true;
2) My API post method:
[HttpPost] public HttpResponseMessage Create(ItemRegisterViewModel model) { HttpResponseMessage responseMessage = new HttpResponseMessage(); ResponseObject responseObject = new ResponseObject(); UnitOfWork unitOfWork = new UnitOfWork(_database); responseObject.IsSuccess = true; if (ModelState.IsValid) { try { List
Hello Sndp,
Is this more of a general error with Umbraco, than the Umbraco Forms addon product itself?
But to answer your question as you are missing [HttpGet] attribute on the method then ASP.NET MVC will not allow you to do a HTTP Get of that resource, hence the error message it is returning.
I hope that helps you.
Thanks,
Warren
is working on a reply...