How to connect/disconnect user to VPN using Forms authentication in MVC?

Viewed 37

When the user logs in, he will connect with my VPN server, and when he logs out, he will disconnect. Is this possible in a ASP.NET MVC web app using C#?

ASP.NET MVC5

[HttpPost]
[AllowAnonymous]
public ActionResult Login(LoginModel model, string returnUrl)
{
    UsersController uc = new UsersController();
    if (ModelState.IsValid && uc.UserExists(model) && uc.PasswordValid(model))
    {
        FormsAuthentication.SetAuthCookie(model.UserName, false);
        return View("Dashboard");
    }
    // If we got this far, something failed, redisplay form
    ModelState.AddModelError("", "The user name or password provided is incorrect.");
    return View(model);
}

When a valid user completes login, he/she will connect to my VPN server and use services.

0 Answers
Related