asp.net-web-api

Running a STA (Single-Threaded Apartment) thread from a Web API (2.1) controller

你离开我真会死。 提交于 2020-01-06 04:23:06
问题 I'm trying to run a STA (Single-Threaded Apartment) thread from a Web API (2.1) controller. To do this, I'm using StaTaskScheduler: /// <summary>Provides a scheduler that uses STA threads.</summary> public sealed class StaTaskScheduler : TaskScheduler, IDisposable { /// <summary>Stores the queued tasks to be executed by our pool of STA threads.</summary> private BlockingCollection<Task> _tasks; /// <summary>The STA threads used by the scheduler.</summary> private readonly List<Thread>

jQuery.ajax PUT request issue in internet explorer

谁都会走 提交于 2020-01-06 03:53:25
问题 I am working on ASP.NET MVC4 webapi and it seems a put request via $.ajax works fine in case of google chrome and Firefox but it isn't workin in IE(10). The below code : $.ajax({ url: 'api/xQuizQuestion', type: 'PUT', dataType: 'json', data: JSON.stringify(AllQsWithAs), contentType: "application/json;charset=utf-8", success: function (data) { alert('Student added Successfully'); }, error: function () { alert('Student not Added'); } }); Works fine in chrome/firefox, in sense that the data

Not able to post more than 4MB files to Web API

偶尔善良 提交于 2020-01-06 03:48:05
问题 While am posting more than 4MB to my Web API it is throwing error as 404(Not Found) or else if am using ([EnableCors(origins: "http://localhost:61365", headers: " ", methods: " ")]) cors request it is throwing the error like cross origin domain error. Below is my code public class UploaderController : ApiController { [HttpPost] public void UploadFile() { if (HttpContext.Current.Request.Files.AllKeys.Any()) { // Get the uploaded image from the Files collection var httpPostedFile = HttpContext

Json.Net Deserialization of Complex Objects - Base Class that Contains a Base Class as a Property

ぐ巨炮叔叔 提交于 2020-01-06 03:02:08
问题 I have been attempting to resolve this issue for several hours. I have tried many approaches and read many posts. I can't seem to find a resolution. I have an object hierarchy whereby I have derived types that contain another derived type. I am using Json.Net's TypeNameHandling setting. I have it set to Auto on both serialization and deserialization. The resulting JSON is: "[\r\n {\r\n \"$type\": \"Common.Monitors.HeartbeatMonitor, Common\",\r\n \"ClassName\": \"HeartbeatMonitor\",\r\n \

Not getting distributed/disparate Angular site to talk to SignalR in WebAPI

梦想与她 提交于 2020-01-06 02:45:07
问题 I very new to SignalR and I am trying to integrate it with an AngularJS site and WebAPI. I followed greate this example to begin with. However, as I mentioned, the website I am working on will live on a different server to the WebAPI project. In my dev environment I have set up a local site for Angular, hosted in IIS on localhost:60000/127.0.0.1:60000 and the WebAPI lives on localhost:31374 (in VS2013, using IIS Express.) This is to simulate the 2 different servers the projects will live on.

PHP post to WebAPI

家住魔仙堡 提交于 2020-01-06 02:42:18
问题 Well, I know that the headline look simple, but i was looking from 3 days for an example on how to make the POST request to webapi . Currently I am using JQuery to do my POST , but I need some php script to run and talk to my C# webAPI , and it seems impossible to find some examples or explain on how to do that. Someone gave me then Code : $response = file_get_contents('http://localhost:59040/api/Email/SendEmails'); $response = json_decode($response); echo ($response); But this one does

ASP.NET WEB API, unwanted parameters in request

被刻印的时光 ゝ 提交于 2020-01-06 02:20:12
问题 I'm using asp.net web api. I have a method in UserController which receives POST-requests: void Post([FromBoby] UserInfo userInfo) I have a model UserInfo with fields: Login, Name . I can post json: {Login:"someLogin", Name:"someName"} and it will successfully mapped to userInfo parameter. I can also post json: {Login:"someLogin", Name:"someName", UnwantedParameter:"someString"} which will also ssuccessfully mapped to UserInfo parameter and UnwantedParameter will be ignored. How to handle

Multiple IHttpActionResults GET's within a single ApiController fail

假装没事ソ 提交于 2020-01-05 23:05:53
问题 I am playing with WebApi2 and came across an odd issue. I have updated the default ValuesController to use IHttpActionResult like public class ValuesController : ApiController { // GET api/values [HttpGet] public IHttpActionResult Get() { return Ok(new string[] { "value1", "value2" }); } // GET api/values/get2 [HttpGet] public IHttpActionResult Get2() { return Ok(new string[] { "value1", "value2" }); } When I try call Get() within postman I get an error { "Message": "An error has occurred.",

Unable to install EntityFramework 6.1.3 in VS2015 web project

旧城冷巷雨未停 提交于 2020-01-05 17:58:11
问题 In my VS2015 WebApi project, I try to install NuGet package EntityFramework 6.1.3 using the following command from Package Manager. The command runs with success as the message below shows. But the package is still not installed and I get an error when I compile the project: PM> Install-Package EntityFramework Installing NuGet package EntityFramework.6.1.3. Successfully installed 'EntityFramework 6.1.3' to myWebProjectName The compile error : Error NU1001 The dependency EntityFramework >= 6.1

Unable to install EntityFramework 6.1.3 in VS2015 web project

爷,独闯天下 提交于 2020-01-05 17:57:57
问题 In my VS2015 WebApi project, I try to install NuGet package EntityFramework 6.1.3 using the following command from Package Manager. The command runs with success as the message below shows. But the package is still not installed and I get an error when I compile the project: PM> Install-Package EntityFramework Installing NuGet package EntityFramework.6.1.3. Successfully installed 'EntityFramework 6.1.3' to myWebProjectName The compile error : Error NU1001 The dependency EntityFramework >= 6.1