asp.net-web-api

Route attribute routing with query strings when there are multiple routes

北城余情 提交于 2020-02-13 22:24:12
问题 I have this: [HttpGet] [Route("Cats")] public IHttpActionResult GetByCatId(int catId) [HttpGet] [Route("Cats")] public IHttpActionResult GetByName(string name) They are called by providing the query string eg Cats?catId=5 However MVC Web API will say you can't have multiple routes that are the same (both routes are "Cats". How can I get this to work so MVC Web API will recognize them as separate routes? Is there something I can put into the Route property? It says that ? is an invalid

Getting related entities ASP.NET WebApi OData v4 results in “No HTTP resource was found that matches the request URI”

本秂侑毒 提交于 2020-02-13 04:50:06
问题 I followed this asp.net tutorial by Mike Wasson, and managed to set up the related entities just fine, but when I applied this logic to my project the more complex entity relations (in that there are more of them; that's the only difference) wouldn't succeed in an OData call, I got a 404 with this payload: { "error": { "code": "", "message": "No HTTP resource was found that matches the request URI 'http://localhost:19215/Menus(c94f7f98-6987-e411-8119-984be10349a2)/MenuPermissions'.",

Getting related entities ASP.NET WebApi OData v4 results in “No HTTP resource was found that matches the request URI”

孤者浪人 提交于 2020-02-13 04:49:26
问题 I followed this asp.net tutorial by Mike Wasson, and managed to set up the related entities just fine, but when I applied this logic to my project the more complex entity relations (in that there are more of them; that's the only difference) wouldn't succeed in an OData call, I got a 404 with this payload: { "error": { "code": "", "message": "No HTTP resource was found that matches the request URI 'http://localhost:19215/Menus(c94f7f98-6987-e411-8119-984be10349a2)/MenuPermissions'.",

DependencyResolver: Pass parameters

允我心安 提交于 2020-02-07 07:50:11
问题 I use autofac and can pass parameters to my resolve method. How can I do this using microsofts DependencyResolver interface? 回答1: The IDependencyResolver does not support passing parameters directly, as I'm sure you have noticed. However, since you have Autofac under the hood, you're able to resolve a factory delegate that enables you to pass on parameters to the underlying service: var factory = dependencyResolver.GetService<Func<int, string, IService>>(); var service = factory(5, "42");

DependencyResolver: Pass parameters

允我心安 提交于 2020-02-07 07:50:03
问题 I use autofac and can pass parameters to my resolve method. How can I do this using microsofts DependencyResolver interface? 回答1: The IDependencyResolver does not support passing parameters directly, as I'm sure you have noticed. However, since you have Autofac under the hood, you're able to resolve a factory delegate that enables you to pass on parameters to the underlying service: var factory = dependencyResolver.GetService<Func<int, string, IService>>(); var service = factory(5, "42");

JQuery AJAX: How to iterate in json and build html table [duplicate]

大城市里の小女人 提交于 2020-02-07 05:45:27
问题 This question already has answers here : Using jQuery to build table rows from AJAX response(json) (12 answers) Closed 2 years ago . I have to iterate in json and build html table where i need to append rows. <table id="tblAppointments" class="table table-striped"> <thead class="thead-dark"> <tr> <th scope="col">Doctor Name</th> <th scope="col">Available Date</th> <th scope="col">Available Time</th> </tr> </thead> </table> this is my jquery code $(document).ready(function () { var useremail =

Get RawBody from HttpContext of ActionExecutionContext in ASP.NET Core

扶醉桌前 提交于 2020-02-06 07:36:05
问题 I have a base class where I want to include code that is being executed in all of my controller methods. In my special case, I opted for creating a base class, overwriting OnActionExecution , and having my controller classes inherit from that base class. This works quite well: public class BaseController : Controller { public override void OnActionExecuting(ActionExecutingContext context) { string parsedParameters = string.Empty; if (context.ActionArguments.Count > 0) { inputParameters =

Calling REST Web API using Delphi

巧了我就是萌 提交于 2020-02-06 07:03:50
问题 I have an ASP.NET MVC Web API and I need to call it using Delphi 6. I am trying to use the Indy components (version 9.0.18), I am using the TIdHttp component. I am using the REST methods, like POST to add, PUT to update and DELETE to delete the records. I got successfully adding, updating and getting my records, but I couldn't get successfully to call the DELETE method. It raises an error "HTTP/1.1 400 Bad Request". I tried to debug the Web API, but it appers that the request didn't come,

Calling REST Web API using Delphi

别等时光非礼了梦想. 提交于 2020-02-06 07:02:07
问题 I have an ASP.NET MVC Web API and I need to call it using Delphi 6. I am trying to use the Indy components (version 9.0.18), I am using the TIdHttp component. I am using the REST methods, like POST to add, PUT to update and DELETE to delete the records. I got successfully adding, updating and getting my records, but I couldn't get successfully to call the DELETE method. It raises an error "HTTP/1.1 400 Bad Request". I tried to debug the Web API, but it appers that the request didn't come,

Sending large POST requests with integrated Windows authentication in OWIN self-host

廉价感情. 提交于 2020-02-05 06:16:06
问题 I'm trying to set up an endpoint for authenticated HTTP POST requests that will handle requests whose bodies sit at around 15 kB. I followed the description on MSDN and defined var httpListener = (OwinHttpListener) appBuilder.Properties[typeof(OwinHttpListener).FullName]; httpListener.Listener.AuthenticationSchemeSelectorDelegate = request => request.HttpMethod == "POST" ? AuthenticationSchemes.IntegratedWindowsAuthentication : AuthenticationSchemes.Anonymous; in my Startup.Configuration .