If we have to overload the action Method in asp.net MVC then we can not do it directly. We have to change the ActionName like this code snippet.

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. namespace MvcApplication5.Controllers
  7. {
  8. public class HomeController : Controller
  9. {
  10. public ActionResult GetEmpName()
  11. {
  12. return Content("This is the test Message");
  13. }
  14. [ActionName("GetEmpWithCode")]
  15. public ActionResult GetEmpName(string EmpCode)
  16. {
  17. return Content("This is the test Messagewith Overloaded");
  18. }
  19. }
  20. }
Now to run the controller GetEmpName action method with just give the URL like this:
http://localhost:49389/Home/GetEmpName.

local host

Now to run the controller GetEmpWithCode action method with just give the URL like this:
http://localhost:49389/Home/GetEmpWithCode.

run the controller GetEmpWithCode