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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:01:41+00:00 2026-06-01T05:01:41+00:00

I working on my first ASP.net MVC project and and i got some problems

  • 0

I working on my first ASP.net MVC project and and i got some problems using multi forms in same page.
First i have created 2 partial Class :
(*Register will allow user to register,
*Login it allow user to login.)

Then i used HTML.render to integrate them in my “Logpage”.
So i have To uses 2 different Action. Like this one:

    [HttpPost]
    public ActionResult Login(LogModel.Login Model)
    {
        if (ModelState.IsValid)
        {

            if (LogModel.Login.Verifuser(Model.IDUser, Model.Password))
            {
                FormsAuthentication.SetAuthCookie(Model.IDUser, false);
                if (LogModel.Login.IsAdmin(Model.IDUser, Model.Password))
                {
                    return View("Admin/Index");
                }
                else
                {
                    return View("Agence/Index");
                }
            }
            else
            {
                ModelState.AddModelError("", "Invalide username or Password");
                return View(Model);
            }
        }
        return View(Model);
    }

The problem that on error case i’m redirect to new Page(White page contain validation summary). So i’m wondring how to show this error message in my default page Logpage.

  • 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-01T05:01:43+00:00Added an answer on June 1, 2026 at 5:01 am

    You can solve this with three actions and a complex model.

     public class LoginOrRegisterViewModel
     {
          public Models.RegisterViewModel Register { get; set; }
          public Models.LoginViewModel Login { get; set; }
     }
    
    
     [HttpGet]
     public ActionResult Login()
     {
          return View("Login", new LoginOrRegisterViewModel());
     }
    
     [HttpPost]
     public ActionResult Register(Models.LoginViewModel model)
     {
          if(!ModelState.IsValid)
               return View("Login", new LoginOrRegisterViewModel(){ Register = model });
          else
          {
               //TODO: Validate the user
               //TODO: Write a FormsAuth ticket
               //TODO: Redirect to somewhere
         }
     }
    
     [HttpPost]
     public ActionResult Login(Models.RegistrationViewModel model)
     {
          if(!ModelState.IsValid)
               return View("Login", new LoginOrRegisterViewModel(){ Login = model});
          else
          {
               //TODO: CRUD for registering user
               //TODO: Write forms auth ticket
               //TODO: Redirect
         }
     }
    

    In your code, make sure that you set the action of the Form:

     @model Models.LoginOrRegisterViewModel
    
     @using(Html.BeginForm("Login", "Controller", FormMethod.Post, new { id = "loginForm"}))
     {
           @Html.EditorFor(m => Model.Login)
     }
    
     @using(Html.BeginForm("Register", "Controller", FormMethod.Post, new { id = "registerForm"}))
     {
           @Html.EditorFor(m => Model.Register)
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a project in ASP.NET MVC using EF4 Code-First for the
I'm working on my first ASP.NET MVC 3 app and I've got a page
I'm attempting to get my first ASP.NET web page working on windows using Mono
I'm working on an asp.net-mvc project. I have an Items table and a Tags
First some background, I am currently working on a relatively large Asp.Net MVC application
I'm working on my first real ASP.NET MVC project and I've noticed that the
I am working on asp.net MVC 3 project. I am using EF 4.1 code
I'm working on my first ASP.NET MVC 3 application with utilizes some JavaScript and
I'm working on my first ASP.NET MVC application and have a strange issue. All
I'm using ASP.NET MVC 3 code-first and I have added validation data annotations to

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.