using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.Functions.Worker;
namespace FunctionApp1;
public class Function1
{
[Function("Function1")]
public IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequest req)
{
return new OkObjectResult("Hello World"); //Works fine
}
[Function("Function2")]
public ActionResult Run2([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequest req)
{
return "Hello World"; //Returning Nothing
}
[Function("Function4")]
public ActionResult Run4([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequest req)
{
return new OkObjectResult("Hello World"); //This is how the api's were returning data before, Returning nothing after update
}
[Function("Function3")]
public async Task Run3([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequest req)
{
return await Task.FromResult(new MyReturnType("Jack", "BlacK")); // Returning Nothing
}
public record MyReturnType(string Name, string Surname);
}
Вопросы
Является ли ActionResult не поддерживается в модели , изолированной рабочей модели [/b]? /> Мне не хватает некоторой конфигурации, или является единственным поддерживаемым шаблоном для возврата httpresponsedata /IActionResultты>
Недавно я модернизировал приложение .NET Function из модели [b] рабочей модели < /strong> до модели , изолированной рабочей, < /strong>.
После обновления я заметил, что ни одно из API-результатов, вызванных HTTP. ActionResult < /code>.
Когда я изменил типы возврата на iActionResult < /code>, API снова начали работать.[code]using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Azure.Functions.Worker;
namespace FunctionApp1;
public class Function1 { [Function("Function1")] public IActionResult Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequest req) { return new OkObjectResult("Hello World"); //Works fine }
[Function("Function4")] public ActionResult Run4([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequest req) { return new OkObjectResult("Hello World"); //This is how the api's were returning data before, Returning nothing after update }
public record MyReturnType(string Name, string Surname); } [/code] Вопросы
Является ли ActionResult не поддерживается в модели , изолированной рабочей модели [/b]? /> Мне не хватает некоторой конфигурации, или является единственным поддерживаемым шаблоном для возврата httpresponsedata /IActionResultты>