How to set JsonSerializerOption per request
I have a .NET 7 web api with a route that returns Users. public class User { public Guid? Id { get; set; } public String? Name { get; set; } public Int32? Age { get; set; } public String?…
I have a .NET 7 web api with a route that returns Users. public class User { public Guid? Id { get; set; } public String? Name { get; set; } public Int32? Age { get; set; } public String?…
Consider a controller endpoint like this: [HttpGet] public IActionResult Get() { var resource = _myService.GetSomeResource(); return Ok(resource); } The GetSomeResource() method performs validation on the identity of the caller, like this: public SomeResourceModel GetSomeResource() { _securityVerifier.VerifyCallerHasAccess(); // do stuff to…
EDIT: This question has been significantly restructured, now I've figured out a bit more of the problem and this should clarify things. I am following this tutorial: https://learn.microsoft.com/en-us/azure/app-service/tutorial-dotnetcore-sqldb-app I've deployed my own multiproject app, which works, but I can't get…
I'm trying to consume my asp.net web api in my asp.net core mvc web app which are on the same solution. I configured the solution for multi-project start and they start both. next I tried to consume the API in…
I am getting an error like this when I am trying to get data from another API. Here is the controller code to call API public async Task<IActionResult> Index() { List<Author>? AuthorList = new List<Author>(); using (var httpClient = new…
I am passing empty value in json payload in datetime field. Below is json payload example. Here in dateOf in Loans2021 I am passing "" { "isCompany": null, "Loans2020": { "dateOf": "2022-12-31T19:00:00.000Z", "Amount": 1000, }, "Loans2021": { "Amount": 0, "dateOf":…
I have the following API that works properly [HttpPost("testing")] public string Testing(IFormFile file, string str, int num) { return str + num.ToString(); } What I want to do ideally is to pass "str" and "num" in an object instead of…
Shortly, I'm trying to create some web-API-application and I'm parsing telegram data and I am faced up with a problem. When I get all the JSON, I see that the program can't parse it because some field(text) couldn't resolve the…
PM> Add-Migration InitialCreate Exception calling "SetData" with "2" argument(s): "Type 'Microsoft.VisualStudio.P rojectSystem.VS.Implementation.Package.Automation.OAProject' in assembly 'Microsoft.VisualStudio.ProjectSystem.VS.Implementation, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not marked as serializable." At C:UsersCtop.nugetpackagesentityframework6.0.0toolsEntityFramework.psm1 :609 char:5 + $domain.SetData('project', $project) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException +…
I'm really confused right now. I'm not sure how to implement correctly Currency Exchange from one Currency to another using asp.net core, using this API: Currency Exchange-API What I'm trying to do is when user input Salary it should exchange…