ASP.NET MVC - Navigation Approach -


I have ASP New to MVC My background is in ASP.NET web form, I think this is causing my confusion. I understand that "M" basically represents the data source, "V" represents the resource that I am requesting and "C" indicates whether the end-user is shown. But then I got confused.

For example, I'm just trying to create a login screen. I visit a visitor and they will be presented with a traditional login screen. To accomplish this, I've added the following in the RegisterRoutes method in my Global.asax file:

  route. MapRoute ("login", "{administrator} / {action}", new {administrator = "account", verb = "login", id = ""}}});  

The login process is executed, but this is where I get confused. You see, the login screen is loading for the first time, I just want to show the username / password field. Then on the post, I hope the form is valid and processed. In one attempt to do this, I have made the following method:

  Public function logins () {bool is FormValid = ValidateForm (); If (isFormValid) login user (); Other Showers (); See Return (); }  

My confusion stays with the login action initially, there is no data but next time, I want to validate the data how can I determine whether the action is a postback or No?

Thank you!

The easiest way to handle this is with two functions: for one, for a post . Use AcceptVerbs attribute to accept based on this method. BTW, Default Roots should work fine for this case, because when the controller and action are taken, then you expect that you expect. I thought this scenario was also included in the project template - have you set up a project or is empty using the template? [AcceptVerbs] (Public Login System) [AcceptVerbs] (OpenType) {} [AcceptVerbs (HttpVerbs.Post)] Public Action Result Login (String Username, String Password) {} ​​

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -