Route/redirect to default action by calling the controler in url?

145 Views Asked by At

URL : localhost:4835/Login

public class LoginController : Controller
{
    public ActionResult Index()
    { 'enter code here' }
}

i want to call index without mention a name of action.

1

There are 1 best solutions below

0
SamGhatak On

You should have something like this in your RouteConfig file:

routes.MapRoute(
    name: "Default",
    url: "{controller}/{action}/{id}",
    defaults: new { controller = "Your Default Controller Name", action = "Default Action name(usually Index)", id = UrlParameter.Optional }
);

You can have your own mappings, just provided a sample here.