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 4045340
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:24:49+00:00 2026-05-20T13:24:49+00:00

I have one controller that takes a username and pass and checks against a

  • 0

I have one controller that takes a username and pass and checks against a database. IF the user is authenticated, I want to call an overloaded action on another controller.

My end goal is to authenticate a user against an old table from a MySQL db (I have this part working). Once the user is authenticated, I would like to be able to “automagically” forward the person to the built in MVC registration page but I would like to populate some fields in the view using data obtained from the first controller (the old databse info).

When I try something like what I have below I get an error about the Register() methods being ambiguous. I’ve also tried using the [ActionName(“Register2”)] attribute but then the error returned says it cant find a method named Register2.

    public class MigrateAccountController : Controller
    {
        OldUserRepository oldDb = new OldUserRepository();
        public ActionResult Index()
        {

            return View();
        }
        [HttpPost]
        public ActionResult Index(User u)
        {
            if (oldDb.isValid(u.username, u.password))
                return RedirectToAction("Register", "Account", u);


            return View(u);
        }
    }
    public class AccountController : Controller
    {
        public IFormsAuthenticationService FormsService { get; set; }
        public IMembershipService MembershipService { get; set; }

        protected override void Initialize(RequestContext requestContext)
        {
            if (FormsService == null) { FormsService = new FormsAuthenticationService(); }
            if (MembershipService == null) { MembershipService = new AccountMembershipService(); }

            base.Initialize(requestContext);
        }
        public ActionResult Register(User u)
        {
            return View(u);
        }
        public ActionResult Register()
        {
            ViewBag.PasswordLength = MembershipService.MinPasswordLength;
            return View();
        }
    }
  • 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-05-20T13:24:49+00:00Added an answer on May 20, 2026 at 1:24 pm

    First thing you cannot have the same action name on the same controller that is accessible on the same verb. You need to either change the action name or use a different HTTP verb:

    public class AccountController : Controller
    {
        public IFormsAuthenticationService FormsService { get; set; }
        public IMembershipService MembershipService { get; set; }
    
        protected override void Initialize(RequestContext requestContext)
        {
            if (FormsService == null) { FormsService = new FormsAuthenticationService(); }
            if (MembershipService == null) { MembershipService = new AccountMembershipService(); }
    
            base.Initialize(requestContext);
        }
    
        [HttpPost]
        public ActionResult Register(User u)
        {
            return View(u);
        }
    
        public ActionResult Register()
        {
            ViewBag.PasswordLength = MembershipService.MinPasswordLength;
            return View();
        }
    }
    

    and in order to pass data between actions, well, if you are using GET, you could pass them as query string parameters when redirecting.

    Or IMHO a better way would be not to redirect in this case but simply return the corresponding view by passing it the proper view model:

    [HttpPost]
    public ActionResult Index(User u)
    {
        if (oldDb.isValid(u.username, u.password))
        {
            return View("~/Account/Register.aspx", u);
        }
        return View(u);       
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a controller with typical create methods (one for GET, one for POST).
Fellow coders, i have a function in a codeigniter controller that accepts a couple
I have tried to build a small function that would be use in controller
I'm currently programming an app for iphone that uses the tab bar. One of
OK...I've spent too much time floundering on this one, so I'm passing it on
I am a newbie just started exploring Grails so that I can recommend this
I want to hear developers opinions on the best way to swap views on
I'm creating a web-based online game and am trying to find the best fit
Currently I'am working on an MVC project in which I try to get a
I'm developing my first ASP.NET MVC app and what I'd like to accomplish is

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.