Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I created a controller called UserManagerController.cs. I put it in the folder with our other controllers, including one we call AjaxController.
I cannot reach user manager controller. When I enter the URL /umbraco/api/userManager/whatever I get a 404.
I know this should work, because when I do /umbraco/api/ajax/whatever it works.
The User Manager Controller is inheriting from the UmbracoApiController.
What else can I check? Is there more I need to do to set up a new controller?
Could you post more details? some code sample both ajax and c#?
Just to be more clear what you are trying to achieve.
Just in case you if are trying to make a "post" you should decorate your endpoint with [HttpPost] as the HttpGet is the default method
Here is the JavaScript to call the controller in my view:
<script> $('#newUser').submit(function (e) { e.preventDefault(); var user = $("#user").val(); var password = $("password").val(); $.get("/umbraco/api/userManager/createUser/" + user + "/" + password); });
And here is the method in my controller:
[HttpGet()] [Route("createUser/{user}/{password}")] public void createUser(string user, string password) { Helper.GetUserDetails(user); }
This is just to get it working, once it is working it will be totally different.
Try these 4 things.
1 . Because of your
[Route("createUser/{user}/{password}")]
I think the url should be like that but I may be wrong.
$.get("/umbraco/api/createUser/" + user + "/" + password);
2 . Try add the full Url in your get method just in case...
$.get("{yourDomain}/umbraco/api/userManager/createUser/" + user + "/" + password);
3 .add [FromUri] to parameters
public void createUser([FromUri]string user, [FromUri]string password)
4 . remove the [Route] and do that to ajax
$.get("{yourDomain}/umbraco/api/userManager/createUser?user=" + user + "&password=" + password);
and your controller should look like that
[HttpGet] public void createUser([FromQuery]string user, [FromQuery]string password)
Eventually I believe you need to do an HttpPost as you want to create an account
In that case your controller should look like that
[HttpPost] public void CreateUser([FromBody]RegisterModel model)
and your ajax should look like something that
$.ajax({ url: '{yourDomain}/umbraco/api/userManager/createUser, type: 'POST', data: ({ User: user, Password: password }), contentType: 'application/json; charset=utf-8', dataType: 'json', async: false, cache: false, success: function (result) { }, error: function (xhr, ajaxOptions, thrownError) { alert(xhr.status); } });
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
URL is not reaching controller
I created a controller called UserManagerController.cs. I put it in the folder with our other controllers, including one we call AjaxController.
I cannot reach user manager controller. When I enter the URL /umbraco/api/userManager/whatever I get a 404.
I know this should work, because when I do /umbraco/api/ajax/whatever it works.
The User Manager Controller is inheriting from the UmbracoApiController.
What else can I check? Is there more I need to do to set up a new controller?
Could you post more details? some code sample both ajax and c#?
Just to be more clear what you are trying to achieve.
Just in case you if are trying to make a "post" you should decorate your endpoint with [HttpPost] as the HttpGet is the default method
Here is the JavaScript to call the controller in my view:
And here is the method in my controller:
This is just to get it working, once it is working it will be totally different.
Try these 4 things.
1 . Because of your
I think the url should be like that but I may be wrong.
2 . Try add the full Url in your get method just in case...
3 .add [FromUri] to parameters
4 . remove the [Route] and do that to ajax
and your controller should look like that
Eventually I believe you need to do an HttpPost as you want to create an account
In that case your controller should look like that
and your ajax should look like something that
is working on a reply...