That standard demos for ASP.NET MVC 3 web site user managements include the following login process:
- User enters auth data.
- Data is posted to the server.
- Code that handles authentication attempts checks provided data with DB.
- If everything is OK – calls
FormsAuthentication.SetAuthCookieto set the cookies for the upcomming session requests from the browser. - And redirects user to whereever.
I want to implement a purely jQuery.Ajax – ASP.NET logon mechanism.
I can call MVC site actions from js with no problem. But how do I get this FormsAuthentication.SetAuthCookie cookie data to manually, from JS code put them in a browser cookie store? How do I extract them on the server or in jQuery.ajax success code?
Using MVC 3 you can set an onclick event for your Login button and then send and ajax POST to the logon action. Have the Logon action return a JSON result and control where the user is sent from your javascript function.
In your View add an Id to your form and put a click handler on the button.