Answers for "GET and POST methods with the same Action name in the same Controller"

C#
0

GET and POST methods with the same Action name in the same Controller

public ActionResult Index()
{
    if("GET"==this.HttpContext.Request.RequestType)
    {
        Some Code--Some Code---Some Code for GET
    }
    else if("POST"==this.HttpContext.Request.RequestType)
    {
        Some Code--Some Code---Some Code for POST
    }
    else
    {
        //exception
    }

    return View();
}
Posted by: Guest on April-13-2022
0

GET and POST methods with the same Action name in the same Controller

[HttpGet]
public ActionResult Index()
{
  // your code
  return View();
}

[HttpPost]
[ActionName("Index")]
public ActionResult IndexPost()
{
  // your code
  return View();
}
Posted by: Guest on April-13-2022

Code answers related to "GET and POST methods with the same Action name in the same Controller"

C# Answers by Framework

Browse Popular Code Answers by Language