If we have to overload the action Method in asp.net MVC then we can not do it directly like C#. We have to implement some trick like changing the ActionName like this code snippet.
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace MvcApplication5.Controllers { public class HomeController : Controller { public ActionResult GetEmpName() { return Content("This is the test Message"); } [ActionName("GetEmpWithCode")] public ActionResult GetEmpName(string EmpCode) { return Content("This is the test Messagewith Overloaded"); } } }
Now to run the above controller GetEmpName action method with just give the URL like this
http://localhost:49389/Home/GetEmpName
Now to run the above controller GetEmpWithCode action method with just give the URL like this