Last post Jan 31, 2020 05:25 AM by KathyW
Member
19 Points
185 Posts
Jan 31, 2020 04:07 AM|sudhir.bharti@hotmail.com|LINK
I am trying to add the third party api in my controller for sending SMS
HomeController:
public class HomeController : Nancy.NancyModule {
public string Index() { return "Hello Plivo"; }
}
Route Config
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 } ); }
Problem:
When we run the application its not hitting the index method, any ideas how to do that?
Note: if I change the HomeController to below code its working with the same route config
public class HomeController : Controlle {
Contributor
5961 Points
2466 Posts
Jan 31, 2020 05:25 AM|KathyW|LINK
It works when you use HomeController: Controller because all controllers are derived from the Controller class. You should be using HomeController : Controller.
Member
19 Points
185 Posts
Controller method not routing/hitting
Jan 31, 2020 04:07 AM|sudhir.bharti@hotmail.com|LINK
I am trying to add the third party api in my controller for sending SMS
HomeController:
public class HomeController : Nancy.NancyModule
{
public string Index()
{
return "Hello Plivo";
}
}
Route Config
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 }
);
}
Problem:
When we run the application its not hitting the index method, any ideas how to do that?
Note: if I change the HomeController to below code its working with the same route config
public class HomeController : Controlle
{
public string Index()
{
return "Hello Plivo";
}
}
Contributor
5961 Points
2466 Posts
Re: Controller method not routing/hitting
Jan 31, 2020 05:25 AM|KathyW|LINK
It works when you use HomeController: Controller because all controllers are derived from the Controller class. You should be using HomeController : Controller.