asp.net-web-api

How to make more MapHttpRoutes for MVC 4 Api

☆樱花仙子☆ 提交于 2019-12-31 12:53:39
问题 I have 2 API routes for my API atm, but I want to add more, and the way I am doing it it seems to overwrite each other, so in the code I pasted, only the CreateUser route works. public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapHttpRoute( name: "CreateUser", routeTemplate: "api/{controller}/{cUser}", defaults: new { controller = "User", action = "CreateUser", cUser = RouteParameter.Optional }); routes.MapHttpRoute( name:

Simple WEB API REST Project

£可爱£侵袭症+ 提交于 2019-12-31 12:07:11
问题 What is the best way to create a simple REST API in Visual Studio 2013 using ASP.NET MVC. I just want something with controllers and route config along with any other basic requirements for a HTTP REST API. I don't require any Razor view engine, Javascript or HTML inclusions. How can I create a project without all the unwanted extras, which I usually remove in the past? Thank you. 回答1: It's all in the template you select. In the New Project dialog, select ".NET Framework 4.5" if not already

Authentication / Authorization MVC 5 and Web API - Katana/Owin

纵然是瞬间 提交于 2019-12-31 10:46:58
问题 I'm having problems trying to decide on a route to take on a project I have. I've been reading up on OWIN specs and Katana implementation within .NET. The reason why I'd like to go with the Katana route is because of the owin components associated with ADFS and Token/Cookie generation. I have two projects, one for MVC 5 website, and one for Web API. They may rest of two separate servers in the future, but for now they are on the same. I know I will be using IIS, so the Owin pipeline isn't

Web API nullable required property requires DataMember attribute

痴心易碎 提交于 2019-12-31 09:12:12
问题 I am receiving the following VM on a Web API Post action public class ViewModel { public string Name { get; set; } [Required] public int? Street { get; set; } } When I make a post I get the following error: Property 'Street' on type 'ViewModel' is invalid. Value-typed properties marked as [Required] must also be marked with [DataMember(IsRequired=true)] to be recognized as required. Consider attributing the declaring type with [DataContract] and the property with [DataMember(IsRequired=true)]

How to secure my AngularJS and Web Api application

耗尽温柔 提交于 2019-12-31 08:59:12
问题 I am using AngularJS with ASP.NET Web Api server side. Seems to me like authentication has now become a breeze? Or is this too good to be true? So I'm thinking of using the Web Api's "Individual User Accounts" authentication. And I am thinking that is all I need. As long as every request is authenticated and noone can get any data they shouldn't I shouldn't need to do much more right? Or am I missing some key security fundamentals? 回答1: When it comes to securing the API you have two main

Generating a JS-client based on a ASP.NET WebAPI Controller

怎甘沉沦 提交于 2019-12-31 08:09:09
问题 In modern web-projects that use RESTful API's we often see AJAX-calls like the one below littered around our JavaScript-files. $.ajax({ type: "POST", url: myapp.baseUrl + 'Api/Note', data: ko.mapping.toJSON(note), contentType: 'application/json', }).done(function (response) { // do something }).fail(function (jqxhr) { // do something else }); I love WebAPI, I love Knockout and I love tying the two together. However these AJAX-calls are quite verbose and contain all kinds of details that I am

OData Web API Query Interceptor

ぃ、小莉子 提交于 2019-12-31 06:59:07
问题 OData endpoint is created using ASP.NET Web API 2.0 Trying to create a Query Interceptor in the ODataController like shown in the below code: public class AVMItemController : ODataController { ADWAppContext sampleADW = new ADWAppContext("Server=XXX;Database=XXX;User ID=XXX;password=xxx;Trusted_Connection=false;Encrypt=true"); // GET: odata/AVM [EnableQuery(PageSize=25)] public IQueryable<ADWAppContext.AVMItem> GetAVMItems() { return sampleADW.AVMItems.AsQueryable<ADWAppContext.AVMItem>(); }

Is it possible to create a parameter binding on both FromURI and FromBody?

南楼画角 提交于 2019-12-31 06:03:29
问题 I looked up up the documentation for ASP.NET Web API parameter binding, they seem to have either fromURI and fromBody only. Is it possible to do both? Here is some background info. I'm creating a webhook receiver/handler, where I have control over which URL is the webhook, but I do not have control over what the payload will be like until later stage of the workflow, so I need to take it in as JSON string first. My hope is to be able to set up the route that can take in querystring and also

Is it possible to create a parameter binding on both FromURI and FromBody?

六眼飞鱼酱① 提交于 2019-12-31 06:03:19
问题 I looked up up the documentation for ASP.NET Web API parameter binding, they seem to have either fromURI and fromBody only. Is it possible to do both? Here is some background info. I'm creating a webhook receiver/handler, where I have control over which URL is the webhook, but I do not have control over what the payload will be like until later stage of the workflow, so I need to take it in as JSON string first. My hope is to be able to set up the route that can take in querystring and also

Limit concurrent requests in Azure App Service

瘦欲@ 提交于 2019-12-31 04:46:06
问题 Given the following ASP.NET Web API application Target: .NET Framework 4.6.1 Hosted as Azure App Service I wish to restrict the total number of concurrent HTTP requests to the application. I have looked at https://github.com/stefanprodan/WebApiThrottle but that seems to be focused on different use cases. I would like the equivalent of this setting in IIS: https://forums.asp.net/t/1683143.aspx?Max+concurrent+requests 回答1: This is to avoid attacking a backend service in counterproductive ways.