Controller method #show getting called
There is a footnote in the canonical Rails Routing from the Outside In to the effect:
Rails routes are matched in the order they are specified, so if you have a resources :photos above a get 'photos/poll' the show action's route for the resources line will be matched before the get line. To fix this, move the get line above the resources line so that it is matched first.
As commented, the fix is to specify get 'tickets/calendar' => ...
ahead of resources :tickets
. If the order of routes is in question, you can run rake routes
, which, to the best of my knowledge, should render your routes in the order they are checked.
Spring MVC controller method called for GET but not for POST
newer spring security versions enable csrf by default which leads to strange errors sometimes. Try disabling by .csrf().disable()
in your security config or look here: https://www.baeldung.com/spring-security-csrf
Controller method not getting called in spring mvc
According to path variable concept in spring it should be as follows.you are missing the path variable in the url
@RequestMapping(value = "/home.web/{statechoice}", method = RequestMethod.GET, produces = { "application/xml",
"application/json" })
@ResponseBody
public void getUSCity(@PathVariable("statechoice") String statechoice) {
System.out.println("In getUSCity" + statechoice);
}
And the url you should hit is localhost:7001/SpringMVCAngularJS/home.web/ME according to the spring syntax.where ME is the value that you will get in state choice.
MVC Controller method not getting called
You have defined an ActionLink
which will perform a GET-request when you click on it.
The controller has the method GetFirstName
defined as HttpPost
. Changing this to HttpGet
will make sure the action is available for GET-requests.
Controller Method not getting called
I got the solution myself.
Turns out one cannot have a dash (-
) inside {}
in one's routes.
My route in routes.php
was initially
Route::post('path1/{obj-id}/path2', 'MyController@myMethod');
I changed it to
Route::post('path1/{id}/path2', 'MyController@myMethod');
and now everything works fine.
Sorry for missing the -
in the original question. Thank you all who tried to help.
Get controller and action name from within controller?
string actionName = this.ControllerContext.RouteData.Values["action"].ToString();
string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
.NET Core 1.1 MVC Controller method not getting called
It turns out that the controller's constructor had arguments that were expected to be provided by Dependency Injection, but that weren't. Somehow this caused the behavior I was seeing, although I still don't really understand why I wasn't getting exceptions instead of these empty responses. Anyway, I fixed the code and it's working now.
Related Topics
Ruby on Rails: Converting "Somewordhere" to "Some Word Here"
How to Replace the Characters in a String
Why Is the << Operation on an Array in Ruby Not Atomic
Ruby: How to Call Function Before It Is Defined
Trouble Installing Ruby 1.9.2 with Rvm MAC Os X
Webmock Simulate Failing API (No Internet, Timeout ++)
What's Does the [5.0] in Rails 5's Activerecord::Migration Mean
Ruby Outputting to the Same Line as the Previous Output
Require Ruby File Without .Rb Extension
Ruby - Naming Convention - Letter Case for Acronyms in Class/Module Names
How to Find Out All the Dependencies of a Gem
How to Use Before :All with Capybara
Triple Single Quote VS Triple Double Quote in Ruby