Closed
Description
Description
I'm getting a
System.NullReferenceException: Object reference not set to an instance of an object.
at JsonApiDotNetCore.Middleware.TypeMatchFilter.OnActionExecuting(ActionExecutingContext context) in
C:\projects\jsonapidotnetcore\src\JsonApiDotNetCore\Middleware\TypeMatchFilter.cs:line 34
Using a standard dotnet Core Controller when returning a Json(result)
of type string.
My code is as follows:
namespace Foo.Controllers
{
[Authorize]
public class UploadController : Controller
{
IPhotoService _photoService;
public UploadController(IPhotoService photoService)
{
_photoService = photoService;
}
[Route("api/v1/attachments/upload")]
[HttpPost]
public async Task<IActionResult> PostFileAsync(IFormFile file)
{
if(file == null || file.Length == 0)
return Content("No content in file or file not uploaded");
string path = await _photoService.UploadPhotoAsync(file);
return Json(path);
}
}
}
Looking at the code I'm gonna guess it's something to do with the IsJsonApiRequest
not filtering replies properly?
Environment
- JsonApiDotNetCore Version: 2.5.2
- Other Relevant Package Versions: