37,950 questions
87
votes
2
answers
75k
views
Is there a recommended way to return an image using ASP.NET Web API
What is the best way to return an image with 2 parameters (x and y for resize).
For example
~/api/image12345/200/200
Will return a 200 by 200 jpg/png/or gif
Should I return a System.Drawing.Image ...
86
votes
10
answers
127k
views
How to set start page in dotnet core web api?
I try to build a web application with dotnet core web api,but i do not know how to set index.html as start page which can be done with dotnet framework web api easily. And i tried to use app....
86
votes
8
answers
102k
views
Remotely connect to .net core self hosted web api
I have a simple .net core web api with one action:
[Route("[action]")]
public class APIController : Controller
{
// GET api/values
[HttpGet]
public string Ping()
{
return ...
85
votes
4
answers
133k
views
OWIN Security - How to Implement OAuth2 Refresh Tokens
I am using the Web Api 2 template that comes with Visual Studio 2013 has some OWIN middleware to do User Authentication and the likes of.
In the OAuthAuthorizationServerOptions I noticed that the ...
85
votes
2
answers
44k
views
ASP.net Core RC2 Web API POST - When to use Create, CreatedAtAction, vs. CreatedAtRoute?
What are the fundamental differences of those functions? All I know is all three result in a 201, which is appropriate for a successful POST request.
I only follow examples I see online, but they don'...
84
votes
16
answers
92k
views
Self referencing loop detected - Getting back data from WebApi to the browser
I am using Entity Framework and having a problem with getting parent and child data to the browser. Here are my classes:
public class Question
{
public int QuestionId { get; set; }
public ...
84
votes
1
answer
50k
views
Can't decide between Task<IActionResult>, IActionResult and ActionResult<Thing>
While I do understand the concept of Task, ActionResult, etc. I still feel unsure which would be most intuitive to type in a controller if nothing else is specified.
Taking consideration to be as ...
83
votes
10
answers
237k
views
How to set up a Web API controller for multipart/form-data
I am trying to figure this out. I was not getting any useful error messages with my code so I used something else to generate something. I have attached that code after the error message. I have ...
82
votes
11
answers
141k
views
How to support HTTP OPTIONS verb in ASP.NET MVC/WebAPI application
I've set up an ASP.NET web application starting with an MVC 4/Web API template. It seems as though things are working really well - no problems that I'm aware of. I've used Chrome and Firefox to go ...
81
votes
11
answers
176k
views
Enable CORS in Web API 2
I have client and a server running on different ports. The server is running Web API 2 (v5.0.0-rc1).
I tried installing the Microsoft ASP.NET Web API Cross-Origin Support package and enabled it in ...
81
votes
5
answers
79k
views
Is ApiController deprecated in .NET Core
Is it true that "ApiController will get deprecated in .NET Core"? Asking since I'm planning to use it in new projects.
76
votes
11
answers
94k
views
How to make CORS Authentication in WebAPI 2?
The scenario is simple, I need to log in from another server (different from the API server) to retrieve the access token.
I installed Microsoft.Owin.Cors package on the API Server. In Startup.Auth....
75
votes
24
answers
170k
views
All ASP.NET Web API controllers return 404
I'm trying to get an API Controller to work inside an ASP.NET MVC 4 web app. However, every request results in a 404 and I'm stumped. :/
I have the standard API controller route from the project ...
74
votes
6
answers
92k
views
Using angularjs filter in input element
I hope I haven't missed anything obvious in the doco, if I have I'm sure someone will help.
I'm using asp.net webapi to return a DTO, with date fields. These are serialized using JSON.Net (in format '...
74
votes
10
answers
113k
views
ASP.NET Web API: Non-descriptive 500 Internal Server Error
As title says, I’ve got 500 Internal Server Error from GET request to an IQueryable action. The body of the error is empty. That error happens after my action returns result.
I use ASP.NET Web API RC....
73
votes
6
answers
94k
views
Use Fiddler with Basic Authentication to access RESTful WebAPI
I have a WebAPI that works without issue. I have tested locally and deployed to my server and configured this service in IIS to use Basic Authentication. I am able to browse to my service and I ...
72
votes
8
answers
89k
views
C# unsupported grant type when calling web api
I am trying to perform a Post to my WebAPI from a c# WPF desktop app.
No matter what I do, I get
{"error":"unsupported_grant_type"}
This is what I've tried (and I've tried everything I could find):...
72
votes
2
answers
27k
views
What is the difference between PreserveReferencesHandling and ReferenceLoopHandling in Json.Net?
I am looking at one WebAPI application sample that has this coded:
json.SerializerSettings.PreserveReferencesHandling
= Newtonsoft.Json.PreserveReferencesHandling.Objects;
and another with this ...
72
votes
3
answers
81k
views
Should a REST API be case sensitive or non case sensitive?
At work we got a problem with case sensitive REST api which ignores wrongly spelled parameters without returning any error. In my opinion this is bad. Then it comes the general question:
Should a ...
71
votes
3
answers
89k
views
How to use Newtonsoft.Json as default in Asp.net Core Web Api?
I am new to ASP.Net Web Api Core. I have been using ASP.Net MVC for past few years and I always have written an ActionFilter and used JSON.Net for Serializing data into JSON. So, in that way I ...
71
votes
1
answer
151k
views
Simple post to Web Api
I'm trying to get a post request to work with the web api. Following is my api controller.
public class WebsController : ApiController
{
[HttpPost]
public void PostOne(string id)
{
}
...
71
votes
6
answers
198k
views
How to use a client certificate to authenticate and authorize in a Web API
I am trying to use a client certificate to authenticate and authorize devices using a Web API and developed a simple proof of concept to work through issues with the potential solution. I am running ...
70
votes
8
answers
111k
views
Query string not working while using attribute routing
I'm using System.Web.Http.RouteAttribute and System.Web.Http.RoutePrefixAttribute to enable cleaner URLs for my Web API 2 application. For most of my requests, I can use routing (eg. Controller/param1/...
70
votes
3
answers
72k
views
Can't get UserManager from OwinContext in apicontroller
I'm following a Microsoft sample to implement email validation with Identity 2.0.0
I'm stuck at this part
public ApplicationUserManager UserManager
{
get
{
return _userManager ?? ...
70
votes
3
answers
24k
views
How do we determine whether we are using Web API 1 or Web API 2?
Introduce the problem
I would like to know whether we are using Web API 1 or 2. My own packages.config indicates version 5.0.0. Is that Web API 1 or 2?
Search, and research
I have tried Googling ...