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

  • SEARCH
  • Home
  • 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 9245603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:18:08+00:00 2026-06-18T09:18:08+00:00

I currently have a populated database, a .NET 1.1 website and the task of

  • 0

I currently have a populated database, a .NET 1.1 website and the task of re-writing it in MVC 3. I’ve created the MVC project with Forms Authentication, connected my database to the project, but don’t know the best way to gain access to the information within it.

I came across this link: http://msdn.microsoft.com/en-us/library/f1kyba5e(v=vs.100).aspx?ppud=4, but I’m not sure if this is what I’m looking for in this case.

My goal for today is to get the login page working, so that I can use the admin account to login and see the main page of the site. I’m still very much a rookie with MVC and tend to search too broadly for answers. Hopefully there is something obvious that I’m missing.

  • 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-18T09:18:09+00:00Added an answer on June 18, 2026 at 9:18 am

    You don’t need to write a custom membership provider right away. You could do that at a later stage. If you just want to get your application working with the LogOn screen all you have to do is modify the LogOn method in the default AccountController:

    [HttpPost]
    public ActionResult LogOn(LogOnModel model, string returnUrl)
    {
        if (ModelState.IsValid)
        {
            if (ValidateUser(model.UserName, model.Password))
            {
                FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
                    && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                {
                    return Redirect(returnUrl);
                }
                else
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            else
            {
                ModelState.AddModelError("", "The user name or password provided is incorrect.");
            }
        }
    
        // If we got this far, something failed, redisplay form
        return View(model);
    }
    

    and then all you need is to write a ValidateUser method that will query your database and verify if the user exists:

    private bool ValidateUser(string username, string password)
    {
        // TODO: query your db here and verify if the account exists
    }
    

    Later on you could write a custom Membership provider to avoid mixing db access logic into your controllers and separate the concerns. Here’s a nice videao about writing a custom membership provider: http://www.asp.net/web-forms/videos/how-do-i/how-do-i-create-a-custom-membership-provider

    You don’t need to override all the methods of the MembershipProvider class, only those that you use. In the beginning you could start by overriding only the ValidateUser method to allow for user authenticating in your website using your custom data tables:

    public class MyMembershipProvider : MembershipProvider
    {
        public override bool ValidateUser(string username, string password)
        {
            // put your data access logic here
        }
    
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have an ASP.NET MVC 3 project, plus a class library project, that
I have an existing ASP.Net MVC project that is using entities / repositories in
I have an ASP.NET GridView which is populated from a SQL Server database. This
ASP.Net MVC 3 using C# I currently have a form with some dropdown lists
I currently have a gridview that is populated via database through a c# method.
I currently have a dropdown list being populated with values from a database. I
I have a DataGrid (currently the .NET 3.5 WPFToolkit version, but I can use
I am currently implementing a ListView populated with CheckedTextViews and have everything working just
I currently have one project that currently contains multiple packages. These packages make up
I have a database that was populated using a rails system. I am trying

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.