[HttpPost]
public RegisterViewModel Register(string userName, string password, string companyCode)
{
Route:
public static void Register(HttpConfiguration config)
{
config.Routes.MapHttpRoute("register", "register", new { Controller = "Account", action = "Register" });
Calling from jQuery:
$.ajax({
url : 'http://localhost:5001/register',
type : 'POST',
dataType : 'json',
contentType: "application/json;charset=utf-8",
data: dataObject,
success: function (data) {
.....
Error:
{"Message":"No HTTP resource was found that matches the request URI 'http://localhost:5001/register'.","MessageDetail":"No action was found on the controller 'Account' that matches the request."}
krokonoster
Contributor
4291 Points
1352 Posts
Seems routes work different than in MVC?
Nov 29, 2012 01:28 PM|LINK
Controller:
Action:
[HttpPost] public RegisterViewModel Register(string userName, string password, string companyCode) {Route:
public static void Register(HttpConfiguration config) { config.Routes.MapHttpRoute("register", "register", new { Controller = "Account", action = "Register" });Calling from jQuery:
$.ajax({ url : 'http://localhost:5001/register', type : 'POST', dataType : 'json', contentType: "application/json;charset=utf-8", data: dataObject, success: function (data) { .....Error:
{"Message":"No HTTP resource was found that matches the request URI 'http://localhost:5001/register'.","MessageDetail":"No action was found on the controller 'Account' that matches the request."}javedwahid
Participant
1687 Points
471 Posts
Re: Seems routes work different than in MVC?
Nov 29, 2012 03:35 PM|LINK
If you are using the default mapping for api's it would be 'http://localhost:5001/api/Account/register'
krokonoster
Contributor
4291 Points
1352 Posts
Re: Seems routes work different than in MVC?
Nov 29, 2012 03:42 PM|LINK
That is just a preference, you could make it 'http://localhost:5001/boobs/Account/register' if that tickle your fancy.
I have a GET method routed in exactly the same way without issues, so and educated guess would be that it's related to the http method.
krokonoster
Contributor
4291 Points
1352 Posts
Re: Seems routes work different than in MVC?
Nov 29, 2012 04:01 PM|LINK
Passing Multiple Parameters to ASP.NET Web API With jQuery