I am new in ASP.NET MVC. One of my first task I would like to do is passing a parameter to the HomeController.
To accomplish this I modified default Index method to:
public string Index(string strParam) { return "Param: " + strParam; } I also pass my parameter via url as:
https://localhost:44308/home/index/test but the parameter strParam is always null. How can I pass some parameters to my method using url?
My route config is default:
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); } 