Menu
  • HOME
  • TAGS

Updating Data From MongoDB using Web API

mongodb,web-api

Here is an example of the POST Action. WebApi can perform Model binding so it can take content from the body of the POST action and bind it to a c# entity - in this case the Student object. Here is the content of the Request Body. { "name": "lqbal",...

Visual Studio 2013 publishing fails and reports “non-existing” error

c#,asp.net,visual-studio-2013,web-api,publish

Such errors that disappear shortly usually mean there are some issues with project references. Try to search for the errors messages in the Output panel, it might contain something related to missing references. I also have a suspicion that you would see the same behavior if you ReBuild the solution.

Run multiple request from Action and wait till one ends

c#,multithreading,web-api

Put your tasks in an array and then call Task.WaitAny: var finishedTask = Task.WaitAny(myTasks); When it's finished finishedTask will be the index of the task in myTasks array that finished. You should then be able to get the result from it. var result = myTasks[finishedTask].Result; Actually, since you want to...

Cannot use multiple options OWIN

c#,web-api,owin

The problem lies in the fact that there is no admin rights. I get an acces denied inner exception. With the use of this in a manifest application file I've made the error go away :) <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> <security> <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> </requestedPrivileges> </security> ...

Create rest service Umbraco 7 backOffice

web-api,umbraco7

Take a look at https://our.umbraco.org/DOCUMENTATION/Reference/WebApi/ - the article explains how to create controllers inheriting from UmbracoApiController. EDIT - I added this example: I made a controller like this: public class PartnersController : UmbracoApiController { public IEnumerable GetPartners(string zip = "") { ... } } Then I used jQuery and AngularJS...

C# input on Layout page using Web API

c#,asp.net-mvc,asp.net-web-api,console-application,web-api

If you want these codes in MVC you need to create MVC application. No other way to do it, in that case. Try to rewrite that in MVC. By the way if you want to show the output in the console application you must use Debug for that. Here is...

how to update multiple data in entityframework through async web api

entity-framework,asp.net-web-api,async-await,web-api,asp.net-web-api2

If I understand your question correctly, it boils down to this: How do I start a long running task from an API call but respond before it is finished. Short Answer: You don't in the API. You delegate to a Service. Long Answer: The error you are getting is most...

Azure AD application roles

asp.net-mvc,web-api,asp.net-web-api2,azure-active-directory,openid-connect

It turns out the following should be added to Startup.Auth: TokenValidationParameters = new System.IdentityModel.Tokens.TokenValidationParameters { ValidateIssuer = true, // map the claimsPrincipal's roles to the roles claim RoleClaimType = "roles", } It is actually configuring 'roles' claim type in order to map it with the default behavior. Excellent explanation is...

Is it possible to eavesdrop http response?

security,encryption,server,web-api,httpresponse

It is easy to eavesdrop an http request and even tamper and modify it before reaching the server.

How to get only Odata.Count without value

odata,web-api

Set the $top to zero and $count to true. For example: http://services.odata.org/V4/Northwind/Northwind.svc/Customers?$count=true&$top=0 returns the count but no results {"@odata.context":"http://services.odata.org/V4/Northwind/Northwind.svc/$metadata#Customers","@odata.count":91,"value":[]} Count is calculated after applying the $filter, but without factoring in $top and $skip. For example: http://services.odata.org/V4/Northwind/Northwind.svc/Customers?$count=true&$top=0&$filter=Country%20eq%20%27Germany%27 informs you...

Update multiple entities in one PUT request (or POST)

c#,ajax,entity-framework,web-api

Typically, HttpPost is for new records and HttpPut is for updating. Here is a really good stackoverflow answer on the differences between the two. PUT vs POST in REST That being said, you can pass in a list in either case: // PUT api/Merchants public HttpResponseMessage PutMerchants([FromBody]List<Merchant> merchants) { }...

Custom required attribute with C# & Web API and using private access modifier with validation context

c#,data-annotations,web-api,requiredfieldvalidator

You don't have to use the _Mappings Property, the code below checks if the related Attribute has a value that matches what you specified in the attribute, If there is a match then it checks to see if the Property you are validating has a value. protected override ValidationResult IsValid(object...

Web API Authentication in ASP.NET 5

c#,asp.net,authentication,web-api,asp.net-5

Indeed, there'll be no OAuthAuthorizationServerMiddleware in ASP.NET 5. If you're looking for the same low-level approach, you should take a look at AspNet.Security.OpenIdConnect.Server: it's an experimental fork of the OAuth2 authorization server middleware that comes with Katana 3 but that targets OpenID Connect, as you already figured out ( OAuth...

Does 'api/SomeEntity/ForOtherEntity/{otherEntityId}' break REST?

rest,design,web-api

No, your URLs does not break any principles of REST - for the simple reason that REST is not concerned about URL structures. I would recommend reading one or two of the "REST" books mentioned at http://www.infoq.com/articles/rest-reading-list to get started on REST. If you further more read through the original...

WebApi GET and multiple POST parameter without model always null

asp.net-mvc,rest,asp.net-web-api,web-api

What you are trying to do in the Post request is not valid as per the HTTP protocol. Each web request can only have 1 body, and while it is possible to pass a single param in a unstructured form it is not possible with two (source Asp.net website here...

Debugging web API back-end and angular front-end as two projects in one solution

angularjs,visual-studio,asp.net-mvc-4,routes,web-api

Because they are running on different ports, you have to specify the full url. A full url goes http(s)://host:port/address So if your backend server was on port 80, you should have your api call http://localhost:80/api/menuItems When a url is relative it will go to the same host so if your...

HttpResponseException thrown during InsertAsync at .NET Backend Mobile service

c#,.net,azure,web-api,azure-mobile-services

The problem is fixed just by removing the [DefaultValue("Available")] Annotation in Azure Mobile Service.

MVC 6 WebAPI returns serialized HttpResponseMessage instead of file stream

asp.net,asp.net-mvc,web-api

After a combination of reading documentation aswell as some trial and error, the problems have been solved. The Azure part was made using the nuGet package "WindowsAzure.Storage" (4.4.1-preview) First the output that got JSON serialized. That required a custom action result to be returned instead. using Microsoft.AspNet.Mvc; using System.IO; using...

How to validate GET url parameters through ModelState with data annotation

c#,validation,rest,web-api,data-annotations

Create your own model... public class YourModel { [//DataAnnotation ...] public string taxCode { get; set; } [//DataAnnotation ...] public string requestCode { get; set; } } And change your signature of your server side controller: [HttpGet] public IHttpActionResult GetActivationStatus([FromUri] YourModel yourmodel) { if (ModelState.IsValid) { ... } } If...

Web API - Set each thread with the HttpRequestMessage id?

c#,.net,multithreading,task-parallel-library,web-api

For context related problems, you can use CallContext.LogicalSetData and CallContext.LogicalGetData, which is merely an IDictionary<string, object> which flows between contexts, and has a copy-on-write (shallow copy) semantics. Since your data is immutable (according to the docs), you can map your correlation id to your threads managed thread id: protected async...

Using Serializable attribute on Model in WebAPI

c#,json,web-api,serializable

By default, Json.NET ignores the Serializable attribute. However, according to a comment to this answer by Maggie Ying (quoted below because comments are not meant to last), WebAPI overrides that behavior, which causes your output. Json.NET serializer by default set the IgnoreSerializableAttribute to true. In WebAPI, we set that to...

Web API cant find apicontroller

c#,asp.net,.net,asp.net-web-api,web-api

You should rename the class from GetCarousel to GetCarouselController as this is the convention for web api routing. As a side note, it may also be preferable to rename it to something more appropriate such as "CarouselController", typically "GetCarousel" is much more appropriate as the name of an action, not...

How to trap server error in getJSON

javascript,jquery,web-api

To catch errors from getJSON, use .fail, not error $.getJSON(uri) .done(function (data) { //do some thing with the result }).fail(function(){ //handle your Error here }); But if you throw a Exception on your server script, it isnt transfered to the client - just the 500 internal server error. I think...

Where to store access tokens?

c#,.net,rest,session,web-api

From a scalability perspective, it is definitely better to produce a token containing the information, sign it on the server, then pass it back to the client to store and return with each request. By signing it on the server, you make it immune to the user tampering with the...

Web API Routing Conflicts

asp.net-mvc,asp.net-web-api,web-api

The presence of the statType parameter in the definition of your third endpoint but not in your /api/stat/getScoreHistory URL means that the first of your three endpoints is the best match. You need to remove the extraneous statType parameter from your last endpoint: [Route("getScoreHistory")] public StatHistory GetStatAccountScoreHistory(UserInfo userInfo) ...

Web API 401 Redirect Azure Active Directory OpenIdConnect

web-api,azure-active-directory,openid-connect

Mixing authentication for MVC (as in web UX) and Web API requires special care. See here for an example of how you can combine the two. I know you already read a lot about the theory behind this, but you you want yet another (not required, the sample above alone...

GET calls to WebAPI

asp.net,xml,vb.net,asp.net-web-api,web-api

I think your approach is wrong. You have simple objects to return, that can be handled easily by the default serializers webapi has to offer. Your returned object type should be IHttpActionResult (webapi2) or HttpResponseMessage. I would NOT go for what @Frank Witte suggested, cause returning the object itself is...

How to save data from visual studio apache cordova project to sql server throght web api?

apache,visual-studio,cordova,web-api,visual-studio-cordova

there are 2 options: in the index.html that is created by the cordova project, use 'ajax Post call' webapi or webservices with Cors enabled and json datatype. create a signalr Server winform or console or service, call this signalr Server in the index.html using JavaScript with Cors enabled. then inside...

Command that will run in every request web api

c#,web-api

No, you can set it as an annotation in your controller through actionfilter attributes. Reference says: You can use filter attributes to mark any action method or controller. If the attribute marks a controller, the filter applies to all action methods in that controller. Edit Actionfilters are placed as annotations...

Connect MongoDB with Web API

c#,mongodb,web-api

The following code should work. Make sure you have the mongo database running in the background. I've modified your code as follows I've added mongo connection URL when creating the MongoClient object so it will connect to local mongo Db. When saving the Books to the DB, instead of trying...

Stop Multiple WebAPI requests from Azure Scheduler

azure,web-api,windows-azure-storage

The Windows Azure Scheduler has a 30 seconds timeout. So we cannot have a long running task called by a scheduler. The overlap of 2 subsequent calls is out of question. Also it seems like having a long running task from a WebAPI is a bad design, because the recycling...

How to configure Web Api 2 and IIS for Basic Authentication?

c#,.net,iis,asp.net-web-api,web-api

Looks like your authorization code can't connect with the database. Comment out the code that connects to the DB and return true regardless and see if it lets you through. Use elimination to narrow down to where the problem is. You need to update the DB connection strings (web.config) etc....

Displaying modelState errorlist from a Web Api service in my view? (MVC 4)

jquery,asp.net-mvc-4,web-api

Here are a few things: 1) Is your ajax call expecting a json response? (eg dataType : "JSON",) and is it getting json as a response? This could be a reason why your response object is empty. You can use the developer console in Chrome or one of the other...

How to use PHP to call web api with POST

php,asp.net,web-api

Normally the call is made through curl extension ( I advise you to take some time to read about it ) . Here is a function I use to make curl requests (in json): function make_curl_request() { $data = []; // data to send $data_string = json_encode($data); $ch = curl_init("http://localhost:8000/function");...

Create instance from web.config and with dependency injection in constructor with Ninject

c#,dependency-injection,ninject,web-api

ideally you would have ILogReporting injected into the service that would use it. public class SomeService : ISomeService { private readonly ILogReporting _logger; public SomeService(ILogReporting logger) { _logger = logger; } // .... code.... } but if you need to request the instance at the time of execution, not creation,...

How to use the same route with different parameter types?

asp.net-web-api,asp.net-mvc-5,asp.net-mvc-routing,web-api,asp.net-web-api-routing

You do like below method declaration with attribute routing enabled: //declare method with guid 1st // GET: users/1D8F6B90-9BD9-4CDD-BABB-372242AD9960 [Route("users/{reference:guid}")] public IHttpActionResult GetUserByReference(Guid reference) and declare other method like below // GET: users/sample%40email.com [Route("users/{emailAddress}")] public IHttpActionResult GetUser(string emailAddress) Please let me know, is this work for you ?...

PHP post to WebAPI

php,post,web,web-api

After Maalls answer from this post How do I send a POST request with PHP? The answer was really simple and the code was the following : $url = 'http://server.com/path'; $data = array('key1' => 'value1', 'key2' => 'value2'); // use key 'http' even if you send the request to https://......

JQuery EasyUI Datagrid works with one web service but not another (same code same servers)

jquery,json,asp.net-web-api,web-api,jquery-easyui

The non working response header doesn't allow CORS - it's missing the Access-Control-Allow-Origin header

Web API routing and a Web API Help Page: how to avoid repeated entries

asp.net-web-api,asp.net-mvc-routing,web-api,asp.net-web-api-helppages

It seems like this is a shortcoming of the ASP.NET Web API help pages. To workaround, I changed the view to exclude these invalid routes from the rendered document. For the above example, I added this Where clause to the loop in ApiGroup.cshtml, changing @foreach (var api in Model){ to...

How to create dymanic function in ASP.NET MVC with Web API and EF

asp.net,asp.net-mvc,entity-framework,generics,web-api

You can have a generic base controller like this: public abstract class BaseController<T> : ApiController where T : class { public virtual IHttpActionResult Post(T obj) { // ...... } // some other common methods } and then you inherit from that controller for each of your entities: public class UsersController...

Web API - Cannot de-serialize request object

json,angularjs,web-api

I finally managed to work out an answer to my problem, but I'm not sure why I needed to do it when so many example I have seen don't require it! Anyway, I have decorated my User object and BaseEntity with the following attribute: [JsonObject(MemberSerialization.OptOut)] Could it be that these...

How to validate email in ASP.NET Web API 2.0?

asp.net,asp.net-web-api,web-api

Below solution worked for me. Thanks for the help. // GET: users/sample%40email.com [Route("users/{emailAddress:regex(\\[A-Z0-9._%+-][email protected][A-Z0-9.-]+\.[A-Z]{2,4})}")] public IHttpActionResult GetUser(string emailAddress) ...

Web API 2.2 - OData v4 (Manually Parsing Uri + Expanding)

odata,web-api,expand

What I ended up doing, was building a new ODataQueryOptions object based off the original request, and then pulling just the SelectExpandClause from that. It doesn't answer my initial question, but it is a somewhat working solution for not having to pass in a ODataQueryOptions parameter. See my Code below:...

Generate routes using client address

c#,asp.net,angularjs,web-api

To quote Scott Allen, "technically, you shouldn't use the Url property in an api controller to generate non-webapi links". I'm no expert on producing restful webapi's but it doesn't seem like a good design if the routing of the returned url is dependant on the routing of the calling website....

Owin self-host Web API 405 method not allowed on DELETE

web-api,owin,katana,http-status-code-405

Ok so I know this is lame but I found the problems minutes after posting this. I did spend about 3 hours trying to figure this out. Apparently the issue was with Routing. My ID is a string so I gave it the action parameter the name of the column...

Passing a time zone into a web api call from moment with nodatime

javascript,c#,web-api,nodatime

I need to know some way to send a value from moment, into the web api preferrably as a ZonedDateTime in the client's time zone. I can then convert it to UTC for persistance in the DB. If that's what you want, then: In your moment.js code, use .format()...

Web API routing not working properly (action names)

c#,web-api

Changing this: [ActionName("Weekday")] public IHttpActionResult GetDayWeek(string q_day) { var day = controller.GetDay(q_day); if (day == null) { return NotFound(); } return Ok(day); } To this: [Route("api/day/weekday/{q_day}")] public IHttpActionResult GetDayWeek(string q_day) { var day = controller.GetDay(q_day); if (day == null) { return NotFound(); } return Ok(day); } Did the trick in...

Using a query to search for a task_name, when function to find by id is already implemented

regex,node.js,mongodb,express,web-api

TL;DR: You need to merge tasks.index and tasks.search route, ie. like this: tasks.index = function(req, res, next) { if (req.query.name !== undefined) { // pass on to next handler return next(); } // the rest of your tasks.index. }); And adjust the Router setup like this: app.get('/tasks', tasks.index); app.get('/tasks', tasks.search);...

JsonMediaTypeFormatter trying to deserialise a property with IgnoreDataMember attribute

json,deserialization,web-api,circular-reference

Well I finally fixed this! Turns out the clue was in the stack trace. There's a validation process that occurs in WebAPI for model binding, and somewhere amongst that process there's a call to something called ShouldValidateType(Type type). That function was returning true for my SavingObjectGraph property, which in turn...

Getting 404 error while calling Web API 2 from MVC 5 application

asp.net-mvc,entity-framework,asp.net-mvc-5,web-api,asp.net-web-api2

The issue has been solved. It was due to missing WebApiConfig.cs file in App_Start folder. I have manually added the file. public class WebApiConfig { public static void Register(HttpConfiguration config) { // Web API configuration and services // Web API routes config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new {...

Error calling HttpClient.GetAsync: The underlying connection was closed

asp.net,asynchronous,web-api

This is wrong, The task is cached so the result can be used later. You are supposed to cache result, not the task. At end of first execution, your HttpClient is closed and when you try to retrieve cached task, it will not work. public class ApiClient : HttpClient {...

Sending data by JSON

json,model-view-controller,asp.net-web-api,web-api

using(var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) streamWriter.Write(json); You are not flushing nor closing the stream, so basically the data never gets to the api. My code: Program.cs - Console App class Program { static void Main(string[] args) { var user = new UserModel {Id = 4, FirstName = "Michael", LastName...

Use JSON data coming from WebApi in AngularJS application

json,angularjs,asp.net-web-api,web-api

I think the transform function gets a json string that you have to deserialize before using it as an object... try sth like: function transformCustomer(data, headersGetter) { var transformed = angular.fromJson(data); console.log(transformed.result[0]); return transformed.result; } Additionally you may look at the docs https://docs.angularjs.org/api/ng/service/$http . There is some code showing how...

webapi data convert into another language

android,json,xamarin,web-api

By using Google translation services i can translate the object data in to 64 Languages. Sample Code: http://android-er.blogspot.in/2009/10/androidtranslate-using-google-translate.html Languages Support: http://ctrlq.org/code/19899-google-translate-languages#languages...

Is it possible to bind to events on a child window from a parent?

javascript,dom,web-api

.addEventListener("onreadystatechange", ...) Event properties start with "on". The event names on the other hand do not. I.e. it should be .addEventListener("readystatechange", ...) I have not tried avoiding the race condition because I know of no way to do so. Ok, I'm not entirely sure how events and auxiliary browsing context...

Is it nessesarry to send credentials on every single request to MVC Web Api?

authentication,asp.net-web-api,web-api

Typically how this works is that the user's authentication token will be stored in a cookie. Once you authenticate the user, you will create a 'session' for them server side. There will be a 'session token' that corresponds with this session. When the user signs in, you will create a...

Can't resolve dependencies in Web Api Controller

c#,asp.net,castle-windsor,web-api,owin

No, you didn't register all the dependencies. Basically, what happened is that you didn't register your controllers explicitly in your container. Windsor tries to resolve unregistered concrete types for you, but because it can't resolve it (caused by an error in your configuration), it return null. It is forced to...

Web API 2.2 - ApiController to ODataController (changing Content Type after setting Formatter)

iframe,odata,web-api,content-type

Actually I got it working the way I wanted, more or less, by using OWIN and writing my own middleware. Basically I wanted a way to force a content-type without having to write a specific oData formatter for each instance. So oData could continue to format whichever way it was...

Why is KnockoutJS not showing the same number of objects as my Web API controller?

knockout.js,asp.net-mvc-5,web-api

ko.observableArray does have a length property, but it is the property of the observableArray function itself, not of the array: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length To get the length of the enclosed array, invoke observableArray then call length: self.object().length. For example in your code, change your alert to: alert(xhr + " " + status...

System.Net.Http.UnsupportedMediaTypeException exception occur in fiddler on running Web API post request in fiddler

asp.net-mvc,post,asp.net-web-api,web-api,fiddler

Try to insert an accept header: Accept: */* Meaning: Give what you have... Or Accept: application/json Meaning: Give me JSON...

httpWebRequest pass and get parameters

asp.net,web-api

If the problem is that the parameters are null in the controller, then you probably just need to add the [FromUri] attribute to the action, like so: [HttpGet] [Route("aapi/somesection/v1/someaction")] public void someaction([FromUri]ModelParams p) { //do some action } ...

Bad Response, Startup Options in OWIN server

c#,web-api,owin

Your ServerTestApp.Program requires a Configuration method. This is the convention that you must follow. public void Configuration(IAppBuilder app) { // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888 } ...

OData Endpoint with .NET

c#,asp.net,visual-studio-2013,odata,web-api

Check your assembly bindings in the web.config. You might need something like this (or you might have to remove one). Ensure that any bindings are pointing to the assemblies existing in your bin folder. <dependentAssembly> <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" /> </dependentAssembly> Also, Update NuGet packages to...

How to I pass a stream from Web API to Azure Blob storage without temp files?

c#,asp.net,azure,web-api,windows-azure-storage

Solved it, with the help of this Gist. Here's how I am using it, along with a clever "hack" to get the actual file size, without copying the file into memory first. Oh, and it's twice as fast (obviously). // Create an instance of our provider. // See https://gist.github.com/JamesRandall/11088079#file-blobstoragemultipartstreamprovider-cs for...

Any HTTP header field for created at semantic?

rest,http-headers,web-api

The header Last-Modified has this meaning: The Last-Modified entity-header field indicates the date and time at which the origin server believes the variant was last modified. It is used in the process called 'Conditional GET'. Client The client alread accessd the resource in the past. If it now requests the...

Passing POST parameter to WEB API2

c#,asp.net,asp.net-web-api,web-api,asp.net-web-api2

You were pretty close. I added a FromBody attribute and specified the content type. I'd also make the properties in your patientMaster object publicly accessible. patientMaster object: public class patientMaster { public patientRequest patientRequest { get; set;} public Authetication Authetication { get; set;} } API Controller: [HttpPost] public string PostTestNew([FromBody]PatientMaster...

Web API actions

.net,web-api

I believe the most RESTful way would be: GET: /api/clients/5/projects This would return all projects for client with ID 5. You could also use: GET: /api/projects?clientId=5 If your caller is likely to use project data whenever they request a client, then include it in the result. Otherwise you're better off...

Count does not return the right count properly

c#,database,linq,web-api

It appears that this is where your error is: where (p.Leeftijd >= leeftijd1 && leeftijd2 <= p.Leeftijd) For example, lets take: leeftijd1 = 0; leeftijd2 = 150; And evaluate: where (p.Leeftijd >= 0 && 150 <= p.Leeftijd) This will only return true if p.Leeftijd >= 150. You need to change...

Controller for Web API, RESTful Web Methods. (With Angular)

c#,angularjs,rest,web-api

Here are the important parts of setting up an app using Angular.js and Asp.Net Web Api index.html <!doctype html> <html class="no-js" lang="" ng-app="demo"> <head> <meta charset="utf-8"> <base href="/"> </head> <body ng-controller="MainController as vm'> <h1>Demo</h1> <div>{{vm.value[0]}}</div> <div>{{vm.value[1]}}</div> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.js"></script> <script...

Pass two JSON object by web client post method C#

c#,post,webclient,web-api

You can create POCO classes for the Requestor, Company like follows and use JSON.net to do the conversion for you. public class Company { public string Id { get; set; } // Other properties } public class Requestor { public string Id { get; set; } public string Email {...

Web API HttpClient PutAsync returning Http 404

rest,web-api,asp.net-web-api2,dotnet-httpclient

I got it working by using the FromBody tag in the controller and then wrapping that parameter in the http request body. An important note to is to prefix the parameter with an "=" sign to make sure it was interpreted correctly by the controller. Also I removed the same...

Is it possible to use WebChannelFactory to make requests to WebAPI/OdataController functions/actions?

asp.net-web-api,web-api,servicecontract,webchannelfactory,odatacontroller

So the answer is a resounding YES. I just implemented the service contract and set up Routing to make the service operations work.

Web API Sync Calls Best Practice

c#,iis,.net-4.5,web-api

Using Task<T>.Result is the equivalent of Wait which will perform a synchronous block on the thread. Having async methods on the WebApi and then having all the callers synchronously blocking them effectively makes the WebApi method synchronous. Under load you will deadlock if the number of simultaneous Waits exceeds the...

WebApi Route returns Not Found in Orchard Module

c#,asp.net-web-api,orchardcms,web-api

Your GET method does not have a parameter id. That might be it

web api FromUri and FromBody attributes misunderstanding

asp.net-web-api,web-api,asp.net-web-api2

This article explain why the [FromUri] is necessary and how to workaround to not need write it anymore. Web API will always try to eagerly bind non-primitive and non-string covnertible types from the body of the request. While in many cases that’s all right, semantically, it doesn’t make much sense...

Access ASP.Net Data Cache from a Web API method in same ASP.Net project

asp.net,web-api,data-caching

Just add reference of System.Web to your Web Api controller and you be able to access Current cache and remove it: System.Web.HttpContext.Current.Cache.Remove("ContentNames"); ...

using angular $http get with asp net web api

asp.net-mvc,angularjs,web-api

angular.module with 1 parameter returns the module with that name - you need to define your module with a list of dependent modules (or empty array if none) like the following: angular.module("api/products", [])... The error referenced gives an error with details on the problem (angular's very good about their error...

OnDisconnected not called when published to IIS server works fine in Visual Studio

iis,model-view-controller,signalr,web-api,signalr-hub

In case anyone else is having this issue. The problem was caused by the application not impersonating the correct user....it worked fine in visual studio because when impersonation failed to use the provided user, it used me. Out side of VS it didn't have that option and tried using the...

How to filter an odata $expand query in a Web-Api controller

entity-framework,odata,web-api,asp.net-web-api2

EF doesn't allow to filter included properties. (This was a highly voted feature request for EF but never implemented: Allow filtering for Include extension method) So, EF doesn't support it. So I can only offer you these two hacks: create a filtered view in the database, and map it to...

access web services with php

php,web-api

The message you are seeing looks to be coming from the web services side, not yours. Chances are that the PHP Notice that's being thrown is invalidating the XML response. Your best bet is to get in contact with the company and report it as a bug.

Having trouble with ASP WebAPI 2.2 and IIS 7 with 404 Error Code

sql-server,iis,web-api

I have seen 404 errors, when making web API calls, where the web API appears to be looking down the physical directory structure for the logical API path. This entry details a fix for those issues that may help. ASP.NET Web API application gives 404 when deployed at IIS 7...

Unity registration fails after iisreset

dependency-injection,unity,web-api

Looks like after the iisreset, the assemblies have not been loaded yet into the app domain by the time your Unity registration kicks in. Since you are using the helper method AllClasses.FromLoadedAssemblies(), it will not register classes in assemblies that were not yet loaded. Try getting the referenced assemblies with...

Iterate Two Lists and Combine Same Values in New Column

c#,asp.net,.net,database,web-api

You can use a Linq join, this will join the 2 lists together and return the items where METERNUMBER exists in both lists but using the longitude/latitude form as400GPSList: List<getBlinksModel> blinkDetailsListWithGPS = (from b in blinkList join a in as400GPSList on b.METERNUMBER equals a.METERNUMBER select new getBlinksModel { METERNUMBER =...

OWIN Service resolution Using Autofac

dependency-injection,web-api,autofac,owin

The IOwinContext.Get uses the Environment dictionary, resolving objects registered directly with Owin, it does not take into account Autofac container. I managed to do it by accessing the Autofac OwinLifetimeScope in the Environment property and using the scope to resolve the service. You can access the LifetimeScope using this code...

How define and call an api Post in c#

c#,web-api

This wasnt easy. After lot of reading I solve it like this. First the api controler need to define the input parameter with the [FromBody] attribute // POST api/survey public void Post([FromBody]string value) { } For testing I put a button in the view and use an Ajax / Post,...

How to Identify Client uniqueness?

api,rest,oauth-2.0,web-api,api-design

Clients are uniquely identified by the client identifier (client_id). The client_id may come back in the result of the Bearer token access validation and the Resource Server may keep a blacklist, although it is more likely that the Authorization Server would blacklist it. If you're looking to improve security by...

Autofac - DelegatingHandler (HttpMessageHandler) Registration

c#,web-api,asp.net-web-api2,autofac,ioc-container

It seems that you can't inject HttpMessageHandler in Web API Given the message handler is passed as instance and being initialized once for the entire service. I think it is easier to have user code inject the dependency themselves first and register the instance with http configuration. This allow people...

Calling async Web API method from App.OnStartup

c#,wpf,asp.net-web-api,async-await,web-api

I suspect that WPF expects StartupUri to be set before OnStartup returns. So, I'd try creating the window explicitly in the Startup event: private async void Application_Startup(object sender, StartupEventArgs e) { HttpResponseMessage response = await TestWebAPIAsync(); if (!response.IsSuccessStatusCode) { MessageBox.Show("The service is currently unavailable"); Shutdown(1); } MainWindow main = new...

cast actionContext.ActionArguments to generic type - problems casting to generic type

c#,web-api,asp.net-web-api2

You can take an easier path to solve this problem. You're trying to cast the object only for reading the Transaction field. What you can do is to create an interface like this: public interface ITransaction { public Transaction Transaction { get; set; } } Then implement it in your...

ServiceLocatorImplBase.cs not found

asp.net-web-api,web-api,ioc-container,structuremap

Thanks for your reply. Both machines are running integrated mode. The error is really misleading and threw me off to a wrong track. I spent hours trying to find where this ServiceLocatorImplBase.cs resides. I happened to look into the deeply nested inner exceptions, and found that the inner most exception...

POST single string Web API

c#,post,httpclient,web-api

When making POST requests the post content should be of type HttpContent or one of its derived types. var content = new FormUrlEncodedContent(new Dictionary<string, string> { {"value" , "buttonOne"} }) ...

Filter Exception Stack Trace from Web API Error?

c#,asp.net,json,web-api

In my code I use the Exception Filters to do what you are asking for, check the following two links for more details Web API Exception Handling Web API global error handling What we do in our code is as follows: Create Exception filter: public class ViewRExceptionFilterAttribute : ExceptionFilterAttribute {...