Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function () {
- var register = function() {
- var dataa = {
- Email: "password@host.com",
- Password: "password",
- ConfirmPassword: "password"
- };
- alert("test");
- $.ajax({
- type: 'POST',
- url: 'api/Account/Register',
- contentType: 'application/json; charset=utf-8',
- data: JSON.stringify(dataa)
- });
- return false;
- }
- $('#btnRegister').click(register);
- });
- [Authorize]
- [RoutePrefix("api/Account")]
- public class AccountController : ApiController
- {
- [AllowAnonymous]
- [Route("Register")]
- public async Task<IHttpActionResult> Register(RegisterBindingModel model)
- {
- if (!ModelState.IsValid)
- {
- return BadRequest(ModelState);
- }
- var user = new ApplicationUser() { UserName = model.Email, Email = model.Email };
- IdentityResult result = await UserManager.CreateAsync(user, model.Password);
- if (!result.Succeeded)
- {
- return GetErrorResult(result);
- }
- return Ok();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement