asp.net-web-api2

POST from Typescript to Web API API, unable to pass a JSON Object

徘徊边缘 提交于 2019-12-11 03:53:27
问题 I am trying to pass a JSON Object from a typescript POST call to a Web API method. Fiddler shows that the object has been converted into JSON and the Content-Type is 'application/JSON'. But at the API controller, the parameter value displays null instead of JSON. Typescript: createPO(product: string): Promise<string> { var headers = new Headers(); headers.append('Content-Type', 'application/json'); let options = new RequestOptions({ headers: headers }); return this._http.post(this._creatPOUrl

custom cors policy not working

a 夏天 提交于 2019-12-11 03:44:41
问题 i have a custom cors policy like below, where I am setting support-credentials to false public class CorsProviderFactory : ICorsPolicyProviderFactory { //https://msdn.microsoft.com/en-us/magazine/dn532203.aspx public ICorsPolicyProvider GetCorsPolicyProvider( HttpRequestMessage request) { return new CorsPolicyProviderCustom(); } public class CorsPolicyProviderCustom : Attribute, ICorsPolicyProvider { private readonly CorsPolicy _policy; public CorsPolicyProviderCustom() { // Create a CORS

Cross domain token based authentication using ASP.NET Identity and ASP.NET Web API 2

别说谁变了你拦得住时间么 提交于 2019-12-11 03:04:25
问题 I would like to know about the best practices to handle this authentication scenario. I have a registration page called (ie https://public.domain.com/#registration), after the registration is done, I'd like to authenticate the user and redirect him to the app (ie https://app.domain.com/). I have another server where I have the authentication method, api controllers, etc (ie https://api.domain.com/Token , https://api.domain.com/api/getOrders , etc). From the registration page (https://public

SignalR: Concurrent connections on Windows 7

旧城冷巷雨未停 提交于 2019-12-11 02:51:55
问题 I have a self-hosted WebAPI which uses SignalR. The process is running on a client OS (Windows 7). Let's assume most clients fall back to long-polling. How many clients can I roughly have? I'm asking because I read Microsoft keeps concurrent connections artificially low on client OS (the article is about IIS though)... In this regard does it matter whether or not clients are using long-polling or WebSockets? 回答1: I don't have a definitive answer regarding request limits for self-hosting on

Web API help page duplicating Action for all areas

安稳与你 提交于 2019-12-11 02:06:11
问题 I'm working with Web API 2, and it seems to pull up my existing API calls already, except it's duplicating all the calls for each area that i have. For example, say i have 3 areas, and in one of those i have an API call that looks like: public IList<string> GetStringList(string id) { //do work here... return new List<string>{"a","b","c"}; } if i have 3 areas, then the web api help page will show: GET area1/api/MyAPIController/GetStringList/{id} GET area2/api/MyAPIController/GetStringList/{id}

Web API - JsonConverter - Custom Attribute

微笑、不失礼 提交于 2019-12-11 01:52:33
问题 We are having a web api project and inorder to convert the date time to date and vice versa, we are using DateTimeconverter extended from JsonConverter. We are using this in the form of an attribute for all the required DateTime properties (as shown below): [JsonConverter(typeof(CustomDateConverter))] The CustomDateConverter is as below: public class CustomDateConverter: JsonConverter { private string[] formats = new string[] { "yyyy-MM-dd", "MM/dd/yy", "MM/dd/yyyy", "dd-MMM-yy" }; public

Web API 2 hosted in IIS 7.5 and Windows server 2008 R2 giving 403.14

♀尐吖头ヾ 提交于 2019-12-11 01:40:14
问题 There are many other questions similar to this in SO, i am still posting here because none of them are working out for my environment. The exact error i am getting is, HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory. Enabling Directory browsing in IIS doesn't help at all. Also tried adding adding all verbs in ExtensionLessUrlHandler-Integrated-4.0 in IIS Handler mappings. And also tried removing module WebDAVModule and WebDAV handler in

Why isn't there an AuthenticationFilterAttribute class in ASP.NET Web API 2?

十年热恋 提交于 2019-12-11 01:39:53
问题 ASP.NET Web API 2 comes with five filter interfaces: IActionFilter IAuthenticationFilter IAuthorizationFilter IExceptionFilter IOverrideFilter All of those interfaces have built-in implementations (e.g. ActionFilterAttribute , AuthorizationFilterAttribute ), except for IAuthenticationFilter . Is there a reason for that or have Web API devs simply forgot to provide an implementation for that particular interface? UPDATE After reading Yishai Galatzer's answer I ended up implementing the

Web API ResponseType for Single Integer

谁说我不能喝 提交于 2019-12-11 01:27:57
问题 What is the "correct" way to have a call to a Web API REST service that simply returns a single integer? I have no requirements here in terms of XML, JSON, or anything else. The call to the service just needs to return an integer. Do I use the ResponseType attribute here? I have the service return type as HttpResponseMessage , and for services such as something returning JSON I would set the Content property on this to StringContent with UTF8 "application/json". But what is correct for a

MVC/SPA Authentication Scenarios for Azure AD

可紊 提交于 2019-12-11 01:26:38
问题 These are Application Types and Scenarios that Azure AD supports: Web Browser to Web Application Native Application to Web API Web Application to Web API Daemon or Server Application to Web API I have two questions: I would like to understand where my scenario below fits. I think I need to use JWT tokens and it seems that Native Application to Web API is the closest, but I still need Asp.Net MVC application to deliver Client side Angular MVC resources (html templates, controllers and Rest