ASP.NET Core Web Api Error for IhttpActionResult2019 Community Moderator ElectionASP.NET Core Web API exception handlingAsp.net Core API with CORS on Service Fabric 100% CPU bottleneckStructuring an ASP.NET Core project to reference .Net Standard librariesReturn file in ASP.Net Core Web APITalking to IdentityServer4 with an Angular SPA application for authentication/authorization receiving a token then talking to Web APIEntity Framework Core with ASP.NET Core Web API and SQL Server (+ Xamarin.Forms)Why doesn't this deadlock in ASP.NET Core Web API?ASP.NET Core (2.1) Web API: Identity and external login providerHow to implement OData Core with async await?Asp .Net Core 2.2 Web Api - Windows authentication from angular app - CORS issue
Why do Australian milk farmers need to protest supermarkets' milk price?
Confusion with the nameplate of an induction motor
Are there situations where a child is permitted to refer to their parent by their first name?
What is the definition of "Natural Selection"?
Counter-example to the existence of left Bousfield localization of combinatorial model category
validation vs test vs training accuracy, which one to compare for claiming overfit?
Replacing Windows 7 security updates with anti-virus?
Is having access to past exams cheating and, if yes, could it be proven just by a good grade?
Is "history" a male-biased word ("his+story")?
Why does Deadpool say "You're welcome, Canada," after shooting Ryan Reynolds in the end credits?
What Happens when Passenger Refuses to Fly Boeing 737 Max?
Can you reject a postdoc offer after the PI has paid a large sum for flights/accommodation for your visit?
Is it true that real estate prices mainly go up?
Format picture and text with TikZ and minipage
When were linguistics departments first established
My story is written in English, but is set in my home country. What language should I use for the dialogue?
What to do when during a meeting client people start to fight (even physically) with each others?
Sword in the Stone story where the sword was held in place by electromagnets
Making a sword in the stone, in a medieval world without magic
Force user to remove USB token
Life insurance that covers only simultaneous/dual deaths
Is all copper pipe pretty much the same?
How to make readers know that my work has used a hidden constraint?
What happens with multiple copies of Humility and Glorious Anthem on the battlefield?
ASP.NET Core Web Api Error for IhttpActionResult
2019 Community Moderator ElectionASP.NET Core Web API exception handlingAsp.net Core API with CORS on Service Fabric 100% CPU bottleneckStructuring an ASP.NET Core project to reference .Net Standard librariesReturn file in ASP.Net Core Web APITalking to IdentityServer4 with an Angular SPA application for authentication/authorization receiving a token then talking to Web APIEntity Framework Core with ASP.NET Core Web API and SQL Server (+ Xamarin.Forms)Why doesn't this deadlock in ASP.NET Core Web API?ASP.NET Core (2.1) Web API: Identity and external login providerHow to implement OData Core with async await?Asp .Net Core 2.2 Web Api - Windows authentication from angular app - CORS issue
I am trying to create a new Core Web API app for the first time. I am using Core 2.2
I did some research but did not find the correct answer. Not sure if I am using wrong libraries.
cannot implicitly convert type microsoft.aspnetcore.mvc.okresult to system.web.http.Ihttpactionresult
Here is my Code
using System.Threading.Tasks;
using System.Web.Http;
using Microsoft.AspNetCore.Mvc;
[Microsoft.AspNetCore.Mvc.Route("api/User")]
[ApiController]
public class UserController : ControllerBase
[Microsoft.AspNetCore.Mvc.HttpGet]
public async Task<IHttpActionResult> GetAllUsers()
var users = await this.GetUserAsync();
return this.Ok(users);
asp.net-core asp.net-core-webapi
add a comment |
I am trying to create a new Core Web API app for the first time. I am using Core 2.2
I did some research but did not find the correct answer. Not sure if I am using wrong libraries.
cannot implicitly convert type microsoft.aspnetcore.mvc.okresult to system.web.http.Ihttpactionresult
Here is my Code
using System.Threading.Tasks;
using System.Web.Http;
using Microsoft.AspNetCore.Mvc;
[Microsoft.AspNetCore.Mvc.Route("api/User")]
[ApiController]
public class UserController : ControllerBase
[Microsoft.AspNetCore.Mvc.HttpGet]
public async Task<IHttpActionResult> GetAllUsers()
var users = await this.GetUserAsync();
return this.Ok(users);
asp.net-core asp.net-core-webapi
1
In addition to the answers below, remove theSystem.Web
dependency. That's going to cause all sorts of issues. ASP.NET Core does not useSystem.Web
so if you see something coming from that namespace, you're doing it wrong.
– Chris Pratt
Mar 6 at 18:27
add a comment |
I am trying to create a new Core Web API app for the first time. I am using Core 2.2
I did some research but did not find the correct answer. Not sure if I am using wrong libraries.
cannot implicitly convert type microsoft.aspnetcore.mvc.okresult to system.web.http.Ihttpactionresult
Here is my Code
using System.Threading.Tasks;
using System.Web.Http;
using Microsoft.AspNetCore.Mvc;
[Microsoft.AspNetCore.Mvc.Route("api/User")]
[ApiController]
public class UserController : ControllerBase
[Microsoft.AspNetCore.Mvc.HttpGet]
public async Task<IHttpActionResult> GetAllUsers()
var users = await this.GetUserAsync();
return this.Ok(users);
asp.net-core asp.net-core-webapi
I am trying to create a new Core Web API app for the first time. I am using Core 2.2
I did some research but did not find the correct answer. Not sure if I am using wrong libraries.
cannot implicitly convert type microsoft.aspnetcore.mvc.okresult to system.web.http.Ihttpactionresult
Here is my Code
using System.Threading.Tasks;
using System.Web.Http;
using Microsoft.AspNetCore.Mvc;
[Microsoft.AspNetCore.Mvc.Route("api/User")]
[ApiController]
public class UserController : ControllerBase
[Microsoft.AspNetCore.Mvc.HttpGet]
public async Task<IHttpActionResult> GetAllUsers()
var users = await this.GetUserAsync();
return this.Ok(users);
asp.net-core asp.net-core-webapi
asp.net-core asp.net-core-webapi
asked Mar 6 at 17:41
ChatraChatra
42611140
42611140
1
In addition to the answers below, remove theSystem.Web
dependency. That's going to cause all sorts of issues. ASP.NET Core does not useSystem.Web
so if you see something coming from that namespace, you're doing it wrong.
– Chris Pratt
Mar 6 at 18:27
add a comment |
1
In addition to the answers below, remove theSystem.Web
dependency. That's going to cause all sorts of issues. ASP.NET Core does not useSystem.Web
so if you see something coming from that namespace, you're doing it wrong.
– Chris Pratt
Mar 6 at 18:27
1
1
In addition to the answers below, remove the
System.Web
dependency. That's going to cause all sorts of issues. ASP.NET Core does not use System.Web
so if you see something coming from that namespace, you're doing it wrong.– Chris Pratt
Mar 6 at 18:27
In addition to the answers below, remove the
System.Web
dependency. That's going to cause all sorts of issues. ASP.NET Core does not use System.Web
so if you see something coming from that namespace, you're doing it wrong.– Chris Pratt
Mar 6 at 18:27
add a comment |
2 Answers
2
active
oldest
votes
You need to use IActionResult
, not IHttpActionResult
.
The IHttpActionResult
interface does not exist in Core, it's used in older Web API projects.
add a comment |
[HttpGet]
public async Task<IActionResult> GetAllUsers()
var users = await this.GetUserAsync()
return Ok(users);
Try changing the type to IActionResult.
According to Microsoft docs: the following components don't exist in ASP.NET Core:
IHttpActionResult
interface
And I don't believe you need this.Ok, it should be fine using just Ok.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55029185%2fasp-net-core-web-api-error-for-ihttpactionresult%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to use IActionResult
, not IHttpActionResult
.
The IHttpActionResult
interface does not exist in Core, it's used in older Web API projects.
add a comment |
You need to use IActionResult
, not IHttpActionResult
.
The IHttpActionResult
interface does not exist in Core, it's used in older Web API projects.
add a comment |
You need to use IActionResult
, not IHttpActionResult
.
The IHttpActionResult
interface does not exist in Core, it's used in older Web API projects.
You need to use IActionResult
, not IHttpActionResult
.
The IHttpActionResult
interface does not exist in Core, it's used in older Web API projects.
edited Mar 6 at 21:40
answered Mar 6 at 17:46
juunasjuunas
23.1k35082
23.1k35082
add a comment |
add a comment |
[HttpGet]
public async Task<IActionResult> GetAllUsers()
var users = await this.GetUserAsync()
return Ok(users);
Try changing the type to IActionResult.
According to Microsoft docs: the following components don't exist in ASP.NET Core:
IHttpActionResult
interface
And I don't believe you need this.Ok, it should be fine using just Ok.
add a comment |
[HttpGet]
public async Task<IActionResult> GetAllUsers()
var users = await this.GetUserAsync()
return Ok(users);
Try changing the type to IActionResult.
According to Microsoft docs: the following components don't exist in ASP.NET Core:
IHttpActionResult
interface
And I don't believe you need this.Ok, it should be fine using just Ok.
add a comment |
[HttpGet]
public async Task<IActionResult> GetAllUsers()
var users = await this.GetUserAsync()
return Ok(users);
Try changing the type to IActionResult.
According to Microsoft docs: the following components don't exist in ASP.NET Core:
IHttpActionResult
interface
And I don't believe you need this.Ok, it should be fine using just Ok.
[HttpGet]
public async Task<IActionResult> GetAllUsers()
var users = await this.GetUserAsync()
return Ok(users);
Try changing the type to IActionResult.
According to Microsoft docs: the following components don't exist in ASP.NET Core:
IHttpActionResult
interface
And I don't believe you need this.Ok, it should be fine using just Ok.
answered Mar 6 at 17:54
porkchop.12porkchop.12
3113
3113
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55029185%2fasp-net-core-web-api-error-for-ihttpactionresult%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
In addition to the answers below, remove the
System.Web
dependency. That's going to cause all sorts of issues. ASP.NET Core does not useSystem.Web
so if you see something coming from that namespace, you're doing it wrong.– Chris Pratt
Mar 6 at 18:27