I\'m trying to navigate to a page which its URL is in the following format: localhost:xxxxx/User/{id}/VerifyEmail?secretKey=xxxxxxxxxxxxxxx
I\'ve added a new route i
In my case I was calling the APi like
http://locahost:56159/api/loginDataController/GetLoginData
while it should be like
http://locahost:56159/api/loginData/GetLoginData
removed Controller from URL and it started working ...
Peace!
In my solution, when I added the my new Controller to the project, the wizard asked me if I want to set the location of the controller into the App_Code folder. The wizard warned me, if I do not locate it into the the App_Code folder, the controller type won't be found. But I didn't read the whole warning, because I wanted to locate the file to elsewhere.. so that's why it didn't work for me.
After I added a new controller and let it to be in the App_Code by default, everything worked.
In my case I was using Web API and I did not have the public
defined for my controller class.
Things to check for Web API:
public
: ApiController
Controller
/api/
prefix. eg. 'host:port/api/{controller}/{actionMethod}'Experienced this similar issue. We are dealing with multiple APIs and we were hitting the wrong port number and getting this error. Took us forever to realize. Make sure the port of the api you are hitting is the correct port.
In my solution, I have a project called "P420" and into other project I had a P420Controller.
When .NET cut controller name to find route, conflict with other project, used as a library into.
Hope it helps.
In my case after spending almost 30 minutes trying to fix the problem, I found what was causing it:
My route defined in WebApiConfig.cs
was like this:
config.Routes.MapHttpRoute(
name: "ControllersApi",
routeTemplate: "{controller}/{action}"
);
and it should be like this:
config.Routes.MapHttpRoute(
name: "ControllersApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
as you see it was interfering with the standard route defined in RouteConfig.cs
.