I posted my observables from js to server-side. But I got this error message from firebug.
"POST http://localhost:54964/Administration/User/CreateUser" 404 Not Found
UserModel.js (my knockoutjs)
return function () {
var self = this;
self.email = ko.observable("");
self.password = ko.observable("");
self.createUser = function () {
console.log("hey");
webRequest.postJSON("/Administration/User/CreateUser", ko.toJSON(self), self.saveSucceeded);
}
self.saveSucceeded = function (result) {
utils.showSuccess("OK..");
window.location.href = "http://" + window.location.host + "/#/Administration/AllUsers";
}
}
I have UserController.cs and CreateUser action in it. However I got this error. My action method cannot be found.
sent observables by a viewmodel
AddUserModel.cs
public class AddUserModel
{
[Required(ErrorMessage = "Eposta alanı boş olamaz.")]
[RegularExpression(@"^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$", ErrorMessage = "Geçerli bir e-posta adresi giriniz")]
public string Email { get; set; }
[Required(ErrorMessage = "Şifre alanı boş olamaz.")]
public string Password { get; set; }
}
And the method that creates an user in the controller.
UserController.cs
[HttpPost]
public ActionResult CreateUser(AddUserModel model)
{
MembershipCreateStatus status;
Membership.CreateUser(model.Email, model.Password, model.Email, null, null, true, out status);
if (status == MembershipCreateStatus.Success)
{
return Json(true);
}
else
{
return new Json(false);
}
}
NOTE: Administration was a "Folder". I changed it as "Area" for area registration. Therefore I deleted Administration "Folder" then added Administration "Area". This may be a reason. I don't know.
Error message= The controller for path '/Administration/User/CreateUser' was not found or does not implement IController.
Why can't controller or action being found?