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.
- 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");
- }
- }
- }
http://localhost:49389/Home/GetEmpName.

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


Chandradev PrasadPosted Dec 14, 2014, 11:54 PM
Thank you Pramod.
Pramod LawatePosted Dec 14, 2014, 1:19 PM
good