web api Web Api: System.Net.Http version not found

When I install the NuGet package for WebApi, it gives me version of System.Net.Http, yet it references version 2. I cannot seem to find version 2 for the life of me. When I download .net 4.5 I get System.Net.Http version 4.0.315.x, but I cannot use that because the Web Api assemblies refer to version Anyone know where I can find this version I've tried the NuGet package manager, mvc4, .net 4.5, and nothing is giving me version 2. Thanks in advance. web api ASP.NET Web API Deserialize Query Parameters into Nested POCO Action Parameter

Already checked this question but didn't answer. Background I have a fully functional RESTful web service written using ASP.NET Web API and it currently supports CORS effectively for cross-origin access from browsers that support CORS. Problem is that current business needs require support of browsers that don't support CORS. I am adding JSON-P support to my web service in addition to supporting CORS and through the magic of action selectors and type formatters, my actual web service code ha web api Best way to return update status from repository layer in ASP.NET MVC WEB API

I am using ASP.NET Web API with Entity Framework and Backbone.js I am working on an update module, where user is allowed to update his XYZ. Now, there are 3 cases which may occur while updating Success Failed Not Found So I have decided to use this enum called enum UpdateStatus { Success = 1, Failed = 0, NotFound = 2 } so here is what my methods will look like public UpdateStatus UpdateXYZ(Model model) { var data = _repo.Table.where(m => ==; if(da web api Output Atom feed with ASP.NET Web API

In my ASP.NET Web API project I have some standard Edit API calls where XML or JSON output or whatever the caller wants is OK for me. But some calls should return ATOM feeds. Now I found out that I can achieve an ATOM or RSS output by a custom MediaTypeFormatter in this post: How to generate ATOM and RSS2 feeds with ASP.NET Web API? But it's not actually what I want as it's still up to the caller to request such an output by an HTTP Accept-header. I want to exclusively return ATOM here, no JSO web api WebApi and MVC in different projects, share cookies?

I've separated my WebApi project into a MVC project ( and a WebApi project ( My MVC project just manages authentication and service up the views (which use knockoutJS and ajax). My problem is that the cookies from the MVC project is not sent when requesting information from the webapi domain (using ajax). Or rather, during testing I'm using two IIS Express servers on different parts. The project is going to be deployed do Azure later, so any solution web api Web API 2 OWIN Bearer token authentication - AccessTokenFormat null?

I have an existing ASP.NET MVC 5 project and I'm adding a Web API 2 project to it. I want to use bearer token authentication and have followed Hongye Sun's tutorial "OWIN Bearer Token Authentication with Web API Sample" and this question as well. In my Login method, for the line Startup.OAuthBearerOptions.AccessTokenFormat.Protect(ticket);, the AccessTokenFormat is null. Any idea why? My AccountController: [RoutePrefix("api")] public class AccountController : ApiController { publi web api how to connect https web api url from windows 8.1 store application

I'm trying to connect to a https web api url from my windows store 8.1 . Im getting this error "the host name in the certificate is invalid or does not match". I need some help on configuring the windows store 8.1 to https. I got certificate from my company and i configured my web api to use this company certificate.When i try to access the web api, my browser is giving error " Certificate Error" Mismatched Address. I need some help to resolve this error and also configuring my application to ac web api How to convert an existing ASP.NET Web API to Azure Mobile Service?

Recently announced at Microsoft Build is the ability to convert an existing ASP.NET Web API to an Azure Mobile Service. I was curious as to if anyone has successfully done this yet, and the steps needed to do so. Things I've tried thus far: Added the Azure Mobile Service .NET Backend & Azure Mobile Service - Entity Framework Nuget Packages to my existing ASP.NET Web API project. Resolved an issue with OWIN and AMS(ZUMO) conflicting Startup.cs assemblies. Ensured the ASP.NET Web API compil web api No "Access-Control-Allow-Origin" header is present

I have put the parameter in the web.config of the web.api that is being called. I even put it in the webapiconfig.cs to allow all sites hit the web.api. Even put it on the controller. And I still get this message? The calling website is sending json over to my web api. Why would I , could I be getting this error? What information can I give you guys to help me figure out this issue? In reply to the solutions listed below: Here is the piece of my web.config....I put the wildcard of asterisk in i web api How to provide custom mediatype formats for OData Api

I am developing an ASP.NET application that uses ODataApiController. The application shows users a grid by querying data and showing it in a table. I would like the ability to export to a number of different formats, including CSV and a custom XML format. Ideally, I would just take the same OData query the grid uses, set the Accepts header, and get back CSV or XML. I've created MediaTypeFormatters to do what I need, but they only work with "regular" ApiController, not ODataApiController. Lo web api Overriding UseBufferedInputStream in Web Api when Attribute Routing is in use

I want to override the buffered input stream for a particular end point which is responsible for upload the files. I've been following the advice in the great article here: And this approach works whenever a templating approach to routing is taken. Like this: config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParamete web api Web API OData Controller Returns "406 - Not Acceptable" When Mapping Results

I've looked at all the SO posts on this and had no success. I'm able to call into the OData controller and see the data retrieved, mapped, and packaged-up. The controller method exits and I get a 406 - Not Acceptable. I'm only using the System.Web.OData namespace (OData Version v4.0.30319) and, using Postman, I manually set the Content and Accept headers to 'application/json' with no luck Maybe I've missed something over the last 2 hours reading everyone's posts on similar problems. Any poi web api Intermittent "Could not load type 'System.Net.Http.Formatting.FormUrlEncodedMediaTypeFormatter'" Error

I am working on a project that includes an ASP.NET WebAPI component. Intermittently, I get the following error: Could not load type 'System.Net.Http.Formatting.FormUrlEncodedMediaTypeFormatter' from assembly 'System.Net.Http.Formatting, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. with the source error pointing to my GlobalConfiguration.Configure() call: Line 35: { Line 36: AreaRegistration.RegisterAllAreas(); Line 37: GlobalConfiguration.Configure web api Manipulate WebAPi POST

I have a WebAPI POST controller like the one below: [ResponseType(typeof(Product))] public async Task<IHttpActionResult> PostProduct(Product product) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Products.Add(product); await db.SaveChangesAsync(); return CreatedAtRoute("DefaultApi", new { id = product.Id }, product); } To be valid, it expects several values, lets say Name, Price, URL, Manufa web api What http status code to return if passed params not valid?

I work on web api project. Here is action method: public async Task<IHttpActionResult> GetDamageEvents(int siteObjectId, int statusId) { try { if (siteObjectId == null || siteObjectId == 0) return (what status?) if (statusId == null || statusId == 0) return (what status?) //some logic return Ok(some result); } catch (Exception) { return BadRequest(); } } As you can see in method above I have two parameters siteObjectId web api authorization has been denied for this request using JWT

I am trying to implement JWT authentication using OWIN middleware for my ASP.NET WebAPI 2.0. I am through with the first task of obtaining the jwt token from the OAuthAuthorizationServer. The resource owner and token server are same i.e same WebAPI generates the token and should consume too to provide access to resources. In my Global.asax file I have added the below code line GlobalConfiguration.Configure(FilterConfig.Configure); In my Filter.config I have added the following configure met web api How to use multiple connection string in entity framework 6.0

I have created a Web API using .net framework and using entity framework 6.0. I have multiple connection strings (suppose 2 connection strings are present in web.config) so that if one server is down then Entity Framework should connect to another server using second connection string. Please suggest how can I achieve this? Regards, Rashi web api Documenting custom error codes from ASP.NET Web API

Are there any best practices for documenting possible error codes returned from a Web API call? I'm referring to custom logic errors as opposed to standard HTTP return codes. For example, consider an API method to allow a user to change their password. A possible error condition might be that the new password provided has already been used by that user previously (ie, password history requirement). You could use the following code to communicate that to the caller: public HttpResponseMessa web api system.webServer/security/authorization in web.config how to migrate to aspcore

I'm using a webapp which uses system.webServer in web.config and have a list of user accounts as roles. <system.webServer> <validation validateIntegratedModeConfiguration="false" /> <security> <authorization> <remove users="*" roles="" verbs="" /> <add accessType="Allow" roles="MOON\USER1" /> <add accessType="Allow" roles="MARS\USER2" /> </authorization> </security> </system.webServe web api Custom Model binder :Can't bind parameter 'xxx' because it has conflicting attributes on it

I am using a custom model binder in order to put some custom logic in my model Binding. Here's my DTOs: public class TaskDto { public int Id { get; set; } [MaxLength(100), Required] public string Name { get; set; } public List<StepDto> Steps { get; set; } public List<ResourceDTO> Resources { get; set; } } Step DTO: public class StepDto { public int Id { get; set; } [MaxLength(100)] public string Description { get; set; } public StepType S web api WebApi actionmethod with string parameter notFound

I have two Get methods in my controller one of them with two string parameters and the second one has one string parameter but, when I make a call to method with one string parameter it returns 404, while method with two string parameters works fine. I think I have problems with my routing. RouteConfig.cs: routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter. web api WebApi hosted on Console App in self-contained .NET Core not working

The below code builds but does not work. When I run the code, it builds and host's the API @ http://localhost:5000 but when I try to access the same form my browser using http://localhost:5000/api/test, it does not work? What am I missing? Program.cs using System; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; namespace ConsoleAppCoreV2 { public class Program { public static void Main( web api WebAPI OData and skip/paging in DocumentDB/CosmosDB

This question was previously posted here but I am repeating the question and a summary of the discussion here to have a complete question. I have set up a ODataController in ASP.NET WebAPI with DocumentDB/CosmosDB as a backend. It works quite ok, I return the result of CreateDocumentQuery and $select,$top,$orderby and $filter work fine. However, $skip does not. I know that this is a planned feature (Vote here) but I would like to know if there is any temporary workaround. My plan was to have web api PUT works with POSTMAN but not with AXIOS

I am trying to update a record in the database. The back end is in C# ASP.NET and the front end is in vuejs. GET, POST methods work with POSTMAN and AXIOS. PUT method do works with POSTMAN but not with axios. Below is the trimmed version of the axios. axios({ method: 'PUT', url: 'http://localhost:64427/api/employees/update', header:{ 'Content-Type': 'application/json' }, data: { QUAD: n_emp.QUAD, EMAIL: n_emp.EMAIL, ACTIF_O_N:n_emp.ACTIF_O_N } }).then(resp web api Unable To populate view or view model Updaed

Hi I am following up on this question here and working through a proof of concept for a SPA using our Company database data from a series of examples / articles Using Web API 2 with Entity Framework 6 Unfortunately, when I run the project I get this return This feels like a failure to retrieve the data from the SQL Database (SQL Server 2008R2). However I am getting no error message, which I though I would, I know the data view is there as I have checked in SQL Management studio and in Server web api Using TLS 1.2 with ASP.NET Web API

I have several services written with ASP.NET 4.5.2 that fetch data from an external web service. These services have worked perfectly without error for a year or so. However, the third-party supplier has recently restricted their API to requests from clients using TLS 1.1 or higher. Our services have been failing as they are being rejected by the extrnal web service. I have checked the server we use to host our service - Windows Server 2012 R2 - and this has TLS 1.1 and 1.2 configured (I have web api ASP.NET Core WebAPI project with in-app store Individual User Accounts Visual Studio 2019

I was trying to create a project in visual studio, I chose the option Individual User Account after selecting WebApi project, and now in VS 2019 it seems to be pretty different than before, now some parameters are requested, can anybody give me some examples of how to configure it? It is asking about: Domain Name Application ID Sign-up or Sign-in Policy And by default it is selected like the only option to select: Connect to an existing user store in the cloud web api jwt token in DOTNET WebApi

I literally read the internet through, tried multiple approaches and so on - with no luck. I am trying to make a pretty small WebApi project with a few controllers protected by a jwt token. I generate the token using following code: var secretKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("may the force")); var tokenHandler = new JwtSecurityTokenHandler(); var tokenDescriptor = new SecurityTokenDescriptor { Subject = new ClaimsIdentity(claims.ToArray()), web api How to remove application/json from Swagger-UI included in Swashbuckle for

I have an .net framework (not core) where I am using Swashbuckle to auto generate the Swagger documentation for my API. I have also added Swashbuckle examples. I want to use the SwaggerResponseExample to show example return data, but in the Swagger UI always has the results nested under application/json There is an old issue on this here, but no workaround. Does anyone have any sort of workaround for this? I see no further updates of Swashbuckle (and hence any embedded Swagger UI). web api Swagger: How to format code/json text using asp.nert Swashbuckle

I wish to include some json on my Swagger documentation, in my WebAPI project, where I am using Swashbuckle to generate and display the API Swagger. I see the markdown says we can use the backticks for code examples... So I have added the following /// Data will look something like /// /// ``` /// { /// "results": { /// "a": 1, /// "b": 2 /// } /// } /// ``` /// But when I see this in the Swagger UI there is no indentation... Is there a way t web api Can Breeze.js auto-generate metadata for non-database entities?

I'm building a Single Page App with Breeze.js, WebApi and Entity Framework. I would like to have the EFContextProvider-niceness of auto-generated metadata, but do not want to expose my DB model to the client. I imagine having a bunch of client-specific DTOs. Can I get Breeze/EF to generate metadata for these entities? web api Microsoft Web API: How do you do a Server.MapPath?

Since Microsoft Web API isn't MVC, you cannot do something like this: var a = Request.MapPath("~"); nor this var b = Server.MapPath("~"); because these are under the System.Web namespace, not the System.Web.Http namespace. So how do you figure out the relative server path in Web API ? I used to do something like this in MVC: var myFile = Request.MapPath("~/Content/pics/" + filename); Which would give me the absolute path on disk: "C:\inetpub\wwwroot\myWebFolder\Content\pics\ web api WebApi Odata Windows Store App EndSaveChanges exception

I am trying to create a Windows Store App using a WebApi Odata controller. After some effort I have all the Get requests working, I am now moving onto the CRUD methods, and am getting the following Exception on the EndSaveChanges of the Data Service Context. <?xml version="1.0" encoding="utf-8"?> <m:error xmlns:m=""> <m:code /> <m:message xml:lang="en-US">No HTTP resource was found that matches the request web api OAuth and external auth providers

I am building WebAPI on OWIN that needs authorization. I implemented OAuth 2.0 and I am really happy with it. For now, there is a grant_type "password" authentication implemented and now I need a way to use external authentication systems, i.e. Facebook, Google, etc. The scenario I am trying to figure out is this: iOS/Android app authorizes user with Facebook using native libraries and get Facebook access_key I should get that access_key to my OAuth OWIN backend Test the access key with Faceb web api Receiving a 405 Method Not Allowed using Web API on POST request. How do I fix this?

My action method has the following signature in the controller class: [RoutePrefix("api/fun")] public class FunController : ApiController { [HttpPost] [Route("domagic")] public HttpResponseMessage PerformMagic(string email) { ... } } When I post to it with PostMan in Chrome or the iOS client I'm writing, I get 405 Method Not Allowed. I post to /api/fun/domagic. Changing the request type to GET, gives me an error that essentially tells me that Web API is mapping to a different web api multiple self-hosted webapi on same server

I want to host, mutiple self-hosted webapi's along with the web-site on the same machine / windows 2k8 server. For hosting the website I am using IIS. and for webapi's I would be using self-hosted webapi 2. How do I configure using self-hosted webapi, so that everything can work in sync on same server. So lets say I will host the website at and I will be hosting the webapi at and I am using windows service for the conf web api How to invalidate OAuth token when password is changed?

We use ASP.NET Identity in a Web Api project with SimpleAuthorizationServerProvider, we use OAuth-tokens to authorize each request coming from the client. (Tokens have and expire timespan, we don't use refresh tokens.) When users change their password, I would like to invalidate the tokens they may have, possibly on other devices. Is there any way to explicitly do that? I experimented and saw that the existing tokens work without any problem after a password change, which should be prevented. web api How to use FluentValidation with Web Api 2.0?

I am trying to use Fluent Validation in a web api 2 project but I can't get the Model State to work. I downloaded this nuget package and added this line to my Application_Start FluentValidationModelValidatorProvider.Configure(GlobalConfiguration.Configuration); Then in my model I added [Validator(typeof(LotValidator))] yet my ModelState.IsValid is always valid. I don't know what I am missing or if it the fact that I have my model in a different class project(though I do reference th web api How Web Api application start event get fired?

I have made a REST web api and I thought the application_start() event of a web api should triggered once you start the web service from IIS manager, however, what I have observed to my web api is it only triggered by the first web request which reached to the web service. I was wondering if this is supposed to be or I did it incorrectly? Thanks. web api Web API Methods: Return IHttpActionResult Or IQueryable

I see most comments about Web API methods say they should return IHttpActionResult. When I add a Controller in Visual Studio and I select "Web API 2 Controller With Action For Entity Framework" it entered these two methods (along with POST, PUT, and DELETE). It uses IQueryable to return multiple records instead of IHttpActionResult. Which is correct and why? // GET: api/Trades public IQueryable<Trade> GetTrades() { return db.Trades; } web api 'No connection could be made because the target machine actively refused it' errors when adding UseWindowsAzureActiveDirectoryBearerAuthentication

I have a web api app that implements a REST interface. I have the service successfully running through the debugger and outside of the debugger through IIS (on localhost). I need to add authentication to this service, and so I have added the following startup code which gets called by my startup.cs class. public partial class Startup { public void ConfigureAuth(IAppBuilder app) { app.UseWindowsAzureActiveDirectoryBearerAuthentication( new WindowsAzureActiveDirector web api Get value from DocumentDb does not Work Web API 2 + c#

I am using Web API 2 with Azure DocumentDb. I wrote this code to call the first document who match the string: var x = this.client.CreateDocumentQuery<Product>((await this.collection).DocumentsLink) .Where(x => x.Name == "Hello1") .AsEnumerable() .FirstOrDefault(); but the result is always null. the values of both SelfLink and DocumentsLink are: (await this.collection).SelfLink = "dbs/h4IDAA==/colls/h4IDAPEiOAA=/"; (await this.collection).D web api Authorization in multiple layers

I am building an application/web API with ASP.NET Core and MediatR. The authentication (Google account) is done in ASP.NET Core. The controllers make only thin layer that delegates all the work to MediatR and its request handlers. Regarding authorization, currently, my approach is, I have most controllers decorated with [Authorize] attribute and also respective request handlers in MediatR's pipeline check (via a behavior) if the user was authenticated, so there is a duplicity. My question is, web api Web API not calling correct method

I'm calling the default Account/ResetPassword api but it doesn't get hit. Some other method does and I can't figure out which one. Is there a way to step through the process so I can see which method is being called? Here's the default method: [HttpPost] [AllowAnonymous] [System.Web.Mvc.ValidateAntiForgeryToken] [Route("api/Account/ResetPassword")] public async Task<IHttpActionResult> ResetPassword(ResetPasswordViewModel model) I'm using PostMan to test the call. By the way, thi

  1    2   3   4   5   6  ... 下一页 最后一页 共 16 页