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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:50:10+00:00 2026-05-13T05:50:10+00:00

I am new to ASP.MVC. My background is in ASP.NET Web Forms, I think

  • 0

I am new to ASP.MVC. My background is in ASP.NET Web Forms, I think this is what is causing my confusion. I understand that the “M” basically represents the data source, the “V” represents the resource I’m requesting and the “C” dictates what gets shown to an end-user. But then I get confused.

For instance, I’m just trying to create a Login screen. I envision a user visiting “http://www.myapp.com/Account/Login” and they will be presented with a traditional Login screen. To accomplish this, I have added the following in the RegisterRoutes method in my Global.asax file:

routes.MapRoute(
  "Login",
  "{controller}/{action}",
  new { controller = "Account", action = "Login", id = "" }
);

The Login action executes, but this is where I get confused. You see, the first time the login screen loads, I would expect to just show a username/password field. Then on post, I would expect the form to be validated and processed. In an attempt to do this, I have created the following method:

public ActionResult Login()
{
  bool isFormValid = ValidateForm();
  if (isFormValid)
    LoginUser();
  else
    ShowErrors();

  return View();
}

My confusion rests with the Login action. Initially, there is no data. But the next time, I want to validate the data. How do I determine if the Action is a postback or not?

Thank you!

  • 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-13T05:50:10+00:00Added an answer on May 13, 2026 at 5:50 am

    The easiest way to handle this is with two actions: one for get, one for post. Use the AcceptVerbs attribute to control which gets invoked depending on the method. BTW, the default routes should work just fine for this case since when the controller and action is supplied it gets directed as you would expect. I thought that this scenario was also covered in the project template — did you set up a project using the template or an empty one?

    [AcceptVerbs( HttpVerbs.Get )]
    public ActionResult Login()
    {
    }
    
    [AcceptVerbs( HttpVerbs.Post )]
    public ActionResult Login( string userName, string password )
    {
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to this asp net mvc but got a strong background in
I'm trying to learn ASP.NET MVC 3 coming from a web forms background. I'm
Some background: I create a new ASP.NET MVC 3 WebApplication. Then I add a
I created a new ASP.NET MVC application. The home page looks like this: I
From a brand-new ASP.NET MVC 4 Beta Web Application, I'm re-arranging my folders to
I am thinking about creating my new asp.net mvc web application compatible with native
As some background I prefer the flexibility and benefits that ASP.NET MVC gives me,
I have an ASP.NET MVC 3 (.NET 4) web application. This app fetches data
I am very new to asp.net mvc. I also have no enough background in
I'm new to ASP.NET MVC, coming from a PHP MVC background. It's been kind

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.