wcf-web-api

How do I handle JSONP with WebAPI? [duplicate]

一世执手 提交于 2019-11-30 22:04:53
Possible Duplicate: JSONP with MVC 4 WebApi I have a get method for my WebAPI which is as follows: private T Get<T>(string uri) { T result = default(T); bool isSuccess = true; client .GetAsync(uri) .ContinueWith(task => { // EnsureStatus isSuccess = task.Result.IsSuccessStatusCode; task .Result .Content .ReadAsAsync<T>() .ContinueWith(t => result = t.Result) .Wait(); }) .Wait(); return result; } The result is produced in a JSON format but I want it for JSONP. I have read that ReadAsSync only handles built in mediaformatters. So is there a way I can change it to handle JsonP? EBarr Stealing

Ninject working with WCF Web API Preview 5

隐身守侯 提交于 2019-11-30 19:03:27
Can anybody point me in the right direction to get Ninject working with WCF Web API Preview 5? I have it successfully up and running in my ASP.NET MVC 3 project and also in another internal WCF Service using the Ninject.Extensions.Wcf library. However I cannot get it to work when creating a new MVC 3 project and getting the WebApi.All library from NuGet. I have looked at this stackoverflow post Setting up Ninject with the new WCF Web API but cannot get it working which I believe could be to do with some of the changes in the latest release. I am also unsure which Ninject Libraries to reference

How do I handle JSONP with WebAPI? [duplicate]

我怕爱的太早我们不能终老 提交于 2019-11-30 17:36:48
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: JSONP with MVC 4 WebApi I have a get method for my WebAPI which is as follows: private T Get<T>(string uri) { T result = default(T); bool isSuccess = true; client .GetAsync(uri) .ContinueWith(task => { // EnsureStatus isSuccess = task.Result.IsSuccessStatusCode; task .Result .Content .ReadAsAsync<T>() .ContinueWith(t => result = t.Result) .Wait(); }) .Wait(); return result; } The result is produced in a JSON

Hosting a WCF Web API app on AppHarbor?

纵然是瞬间 提交于 2019-11-30 13:27:32
I've implemented a sample app like the one here . It is a really basic app just to get things started. Everything works fine in IIS on my local machine, I've got it running on my IIS Express as well, but now come the tricky part. I do want to host this on AppHarbor , but I get 404 error. I've started a discussion on the support forum of AppHarbor, and they have taken a screen shot of the error when they run it. It seems like it is something wrong with the routing since the StaticFile handler is used, but I'm just guessing. Does anyone have any suggestions? Try and add <system.webServer>

WCF Web API vs ASP.NET MVC JSON web services [closed]

社会主义新天地 提交于 2019-11-30 12:33:37
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . What is the advantage of using new WCF Web API over ASP.NET MVC 3 to expose a lightweight JSON Web service layer? I like Web API in

Stubbing or Mocking ASP.NET Web API HttpClient

前提是你 提交于 2019-11-30 11:54:40
问题 I am using the new Web API bits in a project, and I have found that I cannot use the normal HttpMessageRequest , as I need to add client certificates to the request. As a result, I am using the HttpClient (so I can use WebRequestHandler ). This all works well, except that it isn't stub/mock friendly, at least for Rhino Mocks. I would normally create a wrapper service around HttpClient that I would use instead, but I would like to avoid this if possible, as there are a lot of methods that I

WCF Web API vs ASP.NET MVC JSON web services [closed]

青春壹個敷衍的年華 提交于 2019-11-30 03:00:23
What is the advantage of using new WCF Web API over ASP.NET MVC 3 to expose a lightweight JSON Web service layer? I like Web API in many ways, but the drawback is that it doesnt work on mono, while MVC 3 does. What are the major differences between the two approaches? It is recognized by Microsoft, that there is some overlap between the two products. However, they do have a different focus: If you are building a web site that consumes JSON from your web service then MVC is probably the best choice. If you are building an API intended to be consumed by a variety of third party clients then WCF

Stubbing or Mocking ASP.NET Web API HttpClient

a 夏天 提交于 2019-11-30 01:31:05
I am using the new Web API bits in a project, and I have found that I cannot use the normal HttpMessageRequest , as I need to add client certificates to the request. As a result, I am using the HttpClient (so I can use WebRequestHandler ). This all works well, except that it isn't stub/mock friendly, at least for Rhino Mocks. I would normally create a wrapper service around HttpClient that I would use instead, but I would like to avoid this if possible, as there are a lot of methods that I would need to wrap. I am hoping that I have missing something—any suggestions on how to stub HttpClient ?

Web services API Keys and Ajax - Securing the Key

徘徊边缘 提交于 2019-11-29 21:25:56
This is probably a generic security question, but I thought I'd ask in the realm of what I'm developing. The scenario is: A web service (WCF Web Api) that uses an API Key to validate and tell me who the user is, and a mix of jQuery and application on the front ends. On the one hand, the traffic can be https so it cannot be inspected, but if I use the same key per user (say a guid), and I am using it in both then there's the chance it could be taken and someone could impersonate the user. If I implement something akin to OAuth, then a user and a per-app key is generated, and that could work -

Dependency Injection in WebAPI with Castle Windsor

孤街醉人 提交于 2019-11-29 20:43:13
I want to implement Dependency Injection in WebApi application using Castle Windsor. I have following sample code - Interface - public interface IWatch { { DateTime GetTime(); } } Following Watch class implements IWatch Interface - public class Watch:IWatch { public DateTime GetTime() { return DateTime.Now; } } WebApi Controller - WatchController as below - public class WatchController : ApiController { private readonly IWatch _watch; public WatchController() { _watch = new Watch(); } //http://localhost:48036/api/Watch public string Get() { var message = string.Format("The current time on the