Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Membership service usage sample inside ASP.NET MVC controller
public class AccountController : Controller
{
private readonly IMembershipService membershipService;
// service initialization is handled by IoC container
public AccountController(IMembershipService membershipService)
{
this.membershipService = membershipService;
}
// .. some other stuff ..
[HttpPost]
public ActionResult Register(RegisterModel model)
{
if (this.ModelSteate.IsValid)
{
// then passes it to the service method and checks for errors
// which returns ServiceResponse<User> with the status of operation and registered user entity
var response = this.membershipService.CreateUser(model);
if (response.Success)
{
FormsAuthentication.SetAuthCookie(response.Value.UserName, createPersistentCookie: false);
return RedirectToAction("Index", "Home");
}
response.Errors.CopyTo(this.ModelState);
}
return View();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.