Tagged Questions
ASP.NET Web API 2 is a framework for building HTTP services for clients like browsers and mobile devices. It is based on the Microsoft .NET Framework and an ideal choice for building RESTful services.
0
votes
1answer
9 views
http.put throwing error in Angular 2 / Web API using Chrome but not IE
I'm trying to get angular 2 working with web api in a test learner project, but I've hit a question with http.put and wondering if anyone can shed some light on it.
I can POST an object to the web ...
0
votes
2answers
15 views
Flag Role Enum with JWT Bearer Token and Custom AuthorizeAttribute
I am currently working on building a Web API that has JWT and OWIN authentication using MVC 5 and Web API 2. I seem to have all of that working as intended. However, I would now like to implement ...
0
votes
1answer
20 views
C# WebAPI HelpPage customization - Url Endpoint
I'm having a really simple issue that I cannot figure out how to word in search results so I'm hoping I can find the solution here by explaining.
I'm exploring the Helppage area in ASP.NET WebAPI. ...
0
votes
0answers
6 views
How to include selfLink and navigationLink in ASP.NET Web API 2 OData v4 responses?
I would like to include the selfLink and navigationLink(s) in my JSON responses like this:
{
"@odata.count": 4,
"@odata.nextLink": http://example.com/v1.0/Entity?$top=2&$skip=2",
"...
1
vote
0answers
20 views
How to do C# Ajax Comet via WebAPI2?
I have a C# ASP.Net (non MVC) project that uses Ajax Comet long-polling. A web page makes a HTTP call to an endpoint handled by a class implementing IHttpAsyncHandler.
If there is nothing to ...
0
votes
0answers
8 views
Is it possible to change @odata in the results using ASP.NET Web API Odata v4
My ASP.NET Web API 2.0 OData v4 service returns:
{
"@odata.context": "http://localhost:3404/v1.0/$metadata#xyz",
"@odata.count": 1,
"value": [{omitted}]
}
Is it possible to change @odata to @...
1
vote
1answer
18 views
How to validate and decode a JWT created by an asp.net Web-Api in JavaScript
I have been following this tutorial on how to create JWT authorization in an asp.net Web API application.
In my case the authentication server will be the same server holding the resources (ie all ...
0
votes
0answers
15 views
WebApi2: Action that depends on UserRole
I have few roles, let's say "Godmode" and "Guest".
I have one route, let's say "[Route("api/show")]".
User authenticated throught http Authorization header.
When "Godmode" user fires my route, I ...
0
votes
0answers
10 views
Repeated modelstate errors
I am building a web api 2 post service. I'm using default model binding and not doing an extra TryUpdateModel(). When I pass back the model state errors, each error is listed twice. I'm not noticing ...
0
votes
0answers
11 views
webapi ignore route : domain/.well-known/apple-app-site-association
i need to add the following file to a webapi site
apple-app-site-association
.well-known/apple-app-site-association
i need to ignore the route so that i can access the file via url.
http://domain/....
0
votes
3answers
56 views
is it becoming more popular to return strings instead of objects from service methods
I seem to remember reading that deserialization was somewhat expensive in C#. I have a C# service that was returning an object. The object will be used as JSON by downstream clients.
Now that JSON ...
1
vote
2answers
25 views
How to Post to WebApi using HttpClient?
I am trying to post to a WebAPI using HttpClient using an authentication token.
However I am always getting default values on the WebAPI method not the actual values I am sending.
This is my code:
...
0
votes
1answer
64 views
How to wait on an async method in third party library - web api
I am using SendGrid (cloud based SMTP service) to send emails from a web api project. I want my application to wait/block (for say 30 secs) until I have a response from SendGrid before returning the ...
0
votes
0answers
9 views
OWIN health middleware response very slow
I have a problem with health endpoint. There is self hosted OWIN WebApi
I have simple health check middleware which first at all middlewares chain. Sometimes health check response time 10-20 seconds (...
0
votes
0answers
13 views
Best practice to save file in Web Api 2 posted by an MVC application
I'd like to post an object along with an image to my Web Api controller from my MVC controller. In all examples it's shown with Ajax queries, multipart/form-data request and so but in this case my ...
0
votes
0answers
17 views
AngularJS gridOptions
I have an angularjs ui.grid but pagination seems not working.It always show only passed elements with no pagination and not totalServerItems passed. Can anyone help me?
My controller is :
var app;
(...
0
votes
0answers
30 views
How to find out which user's access token I receive in OAuth2 callback method
In my app, I need to connect to an external service that uses OAuth2.
The user clicks a "Connect to SystemX"-button in my website and the OAuth2 authorization code flow is initiated.
The flow goes ...
0
votes
0answers
29 views
Error with JSON API Framework
I have a .NET solution containing a DAL project with the configuration for my entities and a Web API Project containing all my entities wich are imported from SQL Server and my controllers are ...
0
votes
1answer
40 views
ASP.NET WebAPI Get overloading
Is it possible to have multiple Get methods with the same number of parameters? For example, I would like to have a Get(int) and a Get(string). I've tried experimenting with this, but it always seems ...
0
votes
1answer
19 views
using http method except actions on web api
asp.net web api controller has standart http method support. GET, POST, DELETE, PATCH. So controller has standart methods of http. For example I have a ProductController. I can get products, delete, ...
0
votes
1answer
17 views
Web api route wint action require names for multiple get method
I have an asp.net mvc controller named product.
public class ProductController : ApiController
{
[HttpGet]
public IHttpActionResult Get()
{
return Ok("product");
}
}
And my ...
0
votes
0answers
30 views
Post build error after migrating to Asp.Net Core, Error while copying sqlite.dll
I have an application developed in Microsoft.Net 4.6.1 using visual studio 2015 update 3 on Windows 10. Application is using Asp.Net Web API 2 with sql lite database as a backend. It uses ...
0
votes
2answers
24 views
Web API Validation not trigger with custom model binder
I'm building Web Service with Web API 5. I'm implementing custom model binder by extending IModelBinder interface to map complex type as a parameter to action. The binding part is working fine. But ...
0
votes
0answers
16 views
Bind form data to different model web api
I've 2 controllers
public class LeadController : ApiController
{
[HttpPost]
public HttpResponseMessage Post(Lead lead)
{
return Request.CreateResponse(HttpStatusCode.OK);
}
}
...
0
votes
1answer
24 views
Setup machine to machine (Console to WebAPI) authorization with identity server3
I am trying to setup authorization from a console app to a WebAPI endpoint using identityserver3 as the authorization service. This is not a self hosted API and it will be public facing. I've tried to ...
0
votes
1answer
11 views
WebApi 2 Call Action From Custom Class in Same Project
I will insert logs from exception handler and i've action for post logs. How can I call my service action properly?
Is creating instance everytime correct?
public class CustomExceptionHandler : ...
0
votes
0answers
12 views
ConfuserEx Winforms Selfhosted WebAPI
I am trying to confuse a Winforms self hosted WebAPI project.
I am using ConfuserEx UI for an exe and two dll files. No packer and settings to Normal.
When the exe gets confused, I get the ...
0
votes
0answers
6 views
Custom Error Handling With Returning Data Web Api 2
There are many way to handle errors globally with ExceptionFilterAttribute or ExceptionHandler but are there any way to return data without using HTTPContext like that;
return new CustomResponse() { ...
0
votes
1answer
32 views
How can I get a User object returned when calling the '/Token' endpoint?
The endpoint normally returns an ticket with, mainly, an auth token. I am calling this in my Web API from a WPF client application, and it would make life much easier for me, and the login process ...
0
votes
0answers
27 views
How to achieve Authentication by Active Directory and Authorization by Active directory group using ASP.Net Identity [on hold]
I would like to know how to achieve the authentication using active directory and authorization (role) assignment based on AD groups by using built-in ASP.Net identity only. Will it be possible to use ...
4
votes
0answers
42 views
Why do I get an HTTP 400 - Bad Request for an apparently successful request?
I have an action filter to trace the success/failure of requests to actions/controllers with the filter. It has this method:
OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
If ...
0
votes
1answer
17 views
Pass Parameters to a API Controller from Workflow HttpSend Control
I need to make a api call from my workflow(Method type is POST), I am using HttpSend control from Microsoft.Activities to do this. I am able to call my api but not able to send parameters from ...
0
votes
0answers
7 views
Ninject with wcf service - Error activating IOAService No matching bindings are available,
I've looked at the answers for this problem on SO but I'm still a bit stuck. I have a web api which is calling a data access layer which is using wcf. I've added ninject by following this blog: http://...
0
votes
0answers
5 views
Global.asax vs Owin MiddleWare: Setting Thread Culture
I have a hybrid asp.net solution with both Webforms and WebAPI 2 (hosted trough owin). I need to make sure that all requests are handled in the correct Culture. Before introducing WebAPI, we had the ...
0
votes
2answers
22 views
Observables not returning the data
I am developing an Angular 2 app which makes web api calls. I am currently using visual studio 2015 ,MVC5 webapi, typescript and Observables to make the web api calls from client script. It looks ...
1
vote
2answers
41 views
asp.net webapi 2 post parameter is always null
I have been trying to figure this our for the last hour, but I can't see what's wrong with it
the post is from a xamarin app that I'm writing, using restsharp portable client
POST http://192.168.30....
0
votes
0answers
11 views
SSO Implementation MVC5 [closed]
I am building a fresh MVC 5 and WebAPI application. I do not want to maintain the user name and password in my application and instead want use the login geteway of the organization Single Sign ...
0
votes
0answers
17 views
OK<T>() and Created<T>() returns Allow-Control-Allow-Origin error
I have an angular application on client and web api 2 on server.
Return type of controller in web api is IHttpActionResult.
When I return OK(), everything is fine.
But when I return following, I get ...
1
vote
1answer
34 views
Web API OData function with TimeSpan
I have a Web API OData v4 service that I've created. I'm trying to create a bound function that has a TimeSpan parameter having a signature defined in the OData controller similar to the below:
...
0
votes
0answers
23 views
Adding new ID to list items WebApi
I'm working on a small project, where I send a list of models from my android device to WebApi.
The data is being transferred okay, but the problem is the logic when the data comes to the WebApi.
...
0
votes
1answer
28 views
Not able to get response header in angular JS from Web API2
Following is the response returned by Web API2 method:
Response Headers
{
"cache-control": "no-cache",
"pragma": "no-cache",
"content-type": "application/json; charset=utf-8",
"expires": "-1"...
0
votes
1answer
31 views
How can I figure out why ASP.NET web api access token expired?
I have a web service implemented by ASP.NET WEB API 2.0 and secure it with bearer token as as described in article here.
And I set the expiry period to 180 days using code
OAuthOptions = new ...
0
votes
1answer
35 views
How to create a Dependency Injection using Microsoft Asp.net WebApi
I have a little experience working with Dependency Injection using Xamarin.Forms, but not in WebApi, What I want is send data through my Interface and execute inside of my Class which is implementing ...
0
votes
1answer
22 views
Web API 2 serializer selection
In web api 2 controller handling request with "Accept: application/xml" header field.
public class ConverterController : ApiController
{
class A {}
public class B {}
public class C : ...
0
votes
2answers
42 views
Web api controller selection by route
I have two different class library that contains same name controllers.
namespace OldApiService{
public class GreetingController: ApiController{
public string Get(){ return "hello from old ...
3
votes
1answer
131 views
+350
Multiple controllers with same URL routes but different HTTP methods
I've got a following two controllers:
[RoutePrefix("/some-resources")
class CreationController : ApiController
{
[HttpPost, Route]
public ... CreateResource(CreateData input)
{
// ...
1
vote
0answers
24 views
Upload Image using WebAPI and Angular
The code below is used to upload images. I would like to know the Annular code for posting data and web Api code to save images on server.
<form novalidate name="f1" ng-submit="SaveFile()">
&...
0
votes
0answers
15 views
Web api for specific information
I have an app that I've built using MVC, and as an exercise I decided to see what it would take to move to web api, so that maybe in the future I can expand the app to include a mobile app, etc.
I'm ...
0
votes
0answers
7 views
HTTP 500.19 on WebAPI2 service
I have a WebAPI2 service that has been in service for quite some time. Now, when testing an application that calls a function in this service, it works great except when calling it from our ...
0
votes
1answer
17 views
RequestContext Principal always null
I have created a token .NET web API endpoint to get an OAuth bearer token. After retriving the token I call another endpoint of my API and I pass in the authorize header my bearer token but if I check ...