asp.net-web-api2

What should be the return type of WEB API Action Method?

纵饮孤独 提交于 2020-08-22 04:45:00
问题 I am developing ASP.NET Web API using .NET Core. This Web API is going to be mainly accessed by UI application (UI will be developed using ASP.NET Core MVC) but in future API may be accessed by other applications as well. In my WEB API all methods are async. If I want client to do content negotiation then what should be the return type of the API action method Task<IActionresult> or Task<SomePOCO> If I want method to always return data in JSON format then what should be return type of the API

What should be the return type of WEB API Action Method?

試著忘記壹切 提交于 2020-08-22 04:44:30
问题 I am developing ASP.NET Web API using .NET Core. This Web API is going to be mainly accessed by UI application (UI will be developed using ASP.NET Core MVC) but in future API may be accessed by other applications as well. In my WEB API all methods are async. If I want client to do content negotiation then what should be the return type of the API action method Task<IActionresult> or Task<SomePOCO> If I want method to always return data in JSON format then what should be return type of the API

What should be the return type of WEB API Action Method?

佐手、 提交于 2020-08-22 04:44:10
问题 I am developing ASP.NET Web API using .NET Core. This Web API is going to be mainly accessed by UI application (UI will be developed using ASP.NET Core MVC) but in future API may be accessed by other applications as well. In my WEB API all methods are async. If I want client to do content negotiation then what should be the return type of the API action method Task<IActionresult> or Task<SomePOCO> If I want method to always return data in JSON format then what should be return type of the API

Unable to get webApi result in controller

纵然是瞬间 提交于 2020-08-11 18:49:28
问题 I am trying to create constraint for route.Based on the access info retrieved from Db,i will choose which route to choose. I have created controller inheriting IRouteConstraint and calling repository,but Unable to get result from httpclient call. Code snippet of my routeConfig routes.MapRoute( name: "Home", url: "{*routelink}", defaults: new { controller = "Home", action = "Index" }, constraints: new { routelink = new UserAccessController("Home") } ); routes.MapRoute( name: "Reports", url: "{

Unable to get webApi result in controller

梦想与她 提交于 2020-08-11 18:48:20
问题 I am trying to create constraint for route.Based on the access info retrieved from Db,i will choose which route to choose. I have created controller inheriting IRouteConstraint and calling repository,but Unable to get result from httpclient call. Code snippet of my routeConfig routes.MapRoute( name: "Home", url: "{*routelink}", defaults: new { controller = "Home", action = "Index" }, constraints: new { routelink = new UserAccessController("Home") } ); routes.MapRoute( name: "Reports", url: "{

Unable to get webApi result in controller

北城余情 提交于 2020-08-11 18:46:12
问题 I am trying to create constraint for route.Based on the access info retrieved from Db,i will choose which route to choose. I have created controller inheriting IRouteConstraint and calling repository,but Unable to get result from httpclient call. Code snippet of my routeConfig routes.MapRoute( name: "Home", url: "{*routelink}", defaults: new { controller = "Home", action = "Index" }, constraints: new { routelink = new UserAccessController("Home") } ); routes.MapRoute( name: "Reports", url: "{

Unable to get webApi result in controller

北慕城南 提交于 2020-08-11 18:46:09
问题 I am trying to create constraint for route.Based on the access info retrieved from Db,i will choose which route to choose. I have created controller inheriting IRouteConstraint and calling repository,but Unable to get result from httpclient call. Code snippet of my routeConfig routes.MapRoute( name: "Home", url: "{*routelink}", defaults: new { controller = "Home", action = "Index" }, constraints: new { routelink = new UserAccessController("Home") } ); routes.MapRoute( name: "Reports", url: "{

Web API Custom Filter not firing

六月ゝ 毕业季﹏ 提交于 2020-08-07 18:02:22
问题 I have created a custom Filter Attribute that will be doing some basic token validation. So I started by just adding a few lines to see with it works correctly but for some reason is it not working. Custom Filter Class /// <summary> /// Basic Token Based Authitication /// </summary> public class BasicTokenValidation : ActionFilterAttribute { /// <summary> /// Validate Token /// </summary> /// <param name="actionContext"></param> public override void OnActionExecuting(HttpActionContext