Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7921769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:42:32+00:00 2026-06-03T16:42:32+00:00

That standard demos for ASP.NET MVC 3 web site user managements include the following

  • 0

That standard demos for ASP.NET MVC 3 web site user managements include the following login process:

  1. User enters auth data.
  2. Data is posted to the server.
  3. Code that handles authentication attempts checks provided data with DB.
  4. If everything is OK – calls FormsAuthentication.SetAuthCookieto set the cookies for the upcomming session requests from the browser.
  5. 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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T16:42:35+00:00Added an answer on June 3, 2026 at 4:42 pm

    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.

    [HttpPost]
    public JsonResult LogOn(LogOnModel model, string returnUrl)
    {
        if (ModelState.IsValid)
        {
            //Do your authentication
            FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
            return Json(true);
        }
    
    // If we got this far, something failed, redisplay form
        return Json(false);
    }
    

    In your View add an Id to your form and put a click handler on the button.

    <% using (Html.BeginForm("LogOn", "Account", FormMethod.Post, new { Id = "frmLogOn" }))
       { %>
        <%: Html.ValidationSummary(true, "Login was unsuccessful. Please correct the errors and try again.")%>
        <div>
            <fieldset>
                <legend>Account Information</legend>
    
                <div class="editor-label">
                    <%: Html.LabelFor(m => m.UserName)%>
                </div>
                <div class="editor-field">
                    <%: Html.TextBoxFor(m => m.UserName)%>
                    <%: Html.ValidationMessageFor(m => m.UserName)%>
                </div>
    
                <div class="editor-label">
                    <%: Html.LabelFor(m => m.Password)%>
                </div>
                <div class="editor-field">
                    <%: Html.PasswordFor(m => m.Password)%>
                    <%: Html.ValidationMessageFor(m => m.Password)%>
                </div>
    
                <div class="editor-label">
                    <%: Html.CheckBoxFor(m => m.RememberMe)%>
                    <%: Html.LabelFor(m => m.RememberMe)%>
                </div>
    
                <p>
                    <input type="submit" value="Log On" onclick="clicked(); return false;" />
                </p>
            </fieldset>
        </div>
    <% } %>
    <script type="text/javascript">
        function clicked() {
            var form = $('#frmLogOn');
            $.ajax({
                type: 'POST',
                url: '/Account/LogOn',
                data: form.serializeObject(),
                success: function (result) {
                    if (result == true) {
                        alert("success");
                        window.top.location = "/Home/Index";
                    }
                    else {
                        alert("failure");
                    }
                },
                error: function (data) {
                    alert("error");
                }
            });
        }
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET WebService that supports standard WSDL based SOAP calls and a
I have the following problem that the standard library doesn't solve well, and I'm
I'm working on an ASP.NET web application for our corporate intranet users. I have
Is there any way to start foobar.js WSH-script in order that standard Task Manager
I've read that by standard first part of e-mail is case sensitive, however I've
We have a coding standard that says all shared (static) fields and methods must
I wonder if it's guaranteed by the C++ standard that single inheritance make the
The standard says that dereferencing the null pointer leads to undefined behaviour. But what
Does the standard guarantee that order of equal elements will not change (eh, forgot
It seems that in a standard Xcode project, the default target automatically updates the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.