locked
Statement RRS feed

  • Question

  • User-1499457942 posted

    Hi

       How the below code works

    [HttpPost]
            [AllowAnonymous]
            [ValidateAntiForgeryToken]
            public ActionResult Login(LoginViewModel Umodel, string returnUrl)
            {
    }

    Secondly what the below line will do

    public ActionResult Login(LoginVwModel Amodel, string returnUrl)

    Thanks

    Wednesday, July 4, 2018 10:19 AM

Answers

  • User-1171043462 posted

    [HttpPost]

    This means the Action method will accept POST calls i.e. Form Submissions.

    [AllowAnonymous]

    Means anyone can access this Action method without any Authentication.

            [ValidateAntiForgeryToken]

    Used to prevent attacks such as cross-site scripting attacks and cross-site request forgery.

     public ActionResult Login(LoginViewModel Umodel, string returnUrl)

    This is a Action method of MVC. It will be called from View when the Form is submitted.

    For an example on Form Submission refer: ASP.Net MVC: Form Submit (Post) example

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 4, 2018 11:08 AM