I'm trying to get this to work in my ASP.Net Web API 2 application. You will notice that this Controller inherits Controller. This is because I need to return a View instead of JSON.
[RoutePrefix("api/Manage")] public class ManageController : Controller { [Route("TestOne")] public async Task<ActionResult> MyTestOne(string value1, string value2) { return View(""); { } Here is the error I'm getting.
<error> <MessageDetail> No type was found that matches the controller named 'Manage'.</MessageDetail> </Error> I need to call the Manage Controller like so.
https://api.domain.com/api/Manage/TestOne?value1=foo&value2=bar
My RouteConfig is configured like so.
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); NOTE: [RoutePrefix("api/Account")] works in my AccountController. This is an API Controller and inherits ApiBase.
Any help is much appreciated! Thanks!
[FromQuery]in front of each string parameter, i.e.MyTestOne([FromQuery] string value1, [FromQuery] string value2). This will give a hint to asp.net to get these values from the querystring.