Skip to main content

All Questions

0 votes
0 answers
19 views

How do I use ValidationAttribute or IModelBinder to ensure that an enum property exists in the JSON body and has a valid value?

Given a model that looks like this: public enum Types { Emergency, Notice, Event } public class Message { public Types Type { get; set; } public string Title { get; set; } } And ...
SiBrit's user avatar
  • 1,490
0 votes
0 answers
38 views

Serializing table data with reference entity with NewtonSoft.Json in ASP.NET 4.8 Web API

I am working on an ASP.NET Web API which returns table data from database using linq2SQL. I need to include reference entity data to response, till only one level. If reference table next referencing ...
Abhash786's user avatar
  • 903
2 votes
1 answer
227 views

Forcing SnakeCaseNamingStrategy doesn't work in ASP.NET MVC

I'm trying to force both serialization and deserialization to use SnakeCaseNamingStrategy but no luck. Here is what I have used in Global.asax.cs: protected void Application_Start() { ...
Hooman Limouee's user avatar
0 votes
1 answer
60 views

Getting error, while trying consume API and display the contents in gridview of ASP.NET Webform

Error: Target type System.Collections.IEnumerable is not a value type or a non-abstract class. Parameter name: targetType. I was trying to consume Web API endpoint with below gridview and C# function....
Guru's user avatar
  • 47
1 vote
1 answer
346 views

Can I redefine output formatter for one controller method in Net Core 6?

All my method in Backend API working fine and return correct JSON by the same way Return OK(obj) Return Unauthorized() Return StatusCode(StatusCodes.Status500InternalServerError, obj) But in one ...
user avatar
1 vote
1 answer
566 views

JsonIgnore attribute is not working in asp.net

My model is using Newtonsoft.Json; ... public class User { public int Id { get; set; } public string Login { get; set; } public string Password { get; set; } ...
Евгений Мартынов's user avatar
1 vote
1 answer
109 views

How to deserialize array of guid ids received from cognito attribute

I have custom attribute in cognito used for mapping third party claims. After mapping is completed(on user login) I receive values as string in this format [bf5ad010-8961-49d7-b068-87f23026f49d, ...
Minja's user avatar
  • 1,222
0 votes
1 answer
234 views

Apply IsoDateTimeConverter to Incoming Request

I created a Web API in .Net, I added the global settings below: var jsonSettings = new JsonSerializerSettings(); jsonSettings .Converters.Add(new IsoDateTimeConverter() { DateTimeFormat = "yyyy-...
Silva's user avatar
  • 675
0 votes
1 answer
148 views

Customize object serialization to Json in c#

I am making an asp.net core web api and i want to return Ok(JsonList) in a specific format I have a list of the following object: public class obj { string schoolName; int studentscount; int ...
Hyroglatos_7700's user avatar
0 votes
4 answers
642 views

How to read the JSON values from the unstructured data in c#?

{ "id": "zd_tags", "value": [ "bp_ticket;pazure_server" ] }, { "id": "itd_priority_1", "value": 900 }, { "id&...
Vanapandi Narayanan's user avatar
-1 votes
1 answer
423 views

Request Model is null when I post it to API

I'm facing a problem doing post requests via .Net6 Web API. I'm a bit confused about it. Since .Net6 we prefer to use System.Text.Json in place of Newtonsoft.Json I have one Bool property in Request ...
Mazhar Hayat's user avatar
0 votes
1 answer
434 views

Json Deserialization in an ASP.NET not working properly

I have an API that returns the following response as string [ { "id": "62a9f8f90346133662624bd3", "referenceID": "test1", "additionalInfoList&...
Robert Rachita's user avatar
-2 votes
1 answer
486 views

Deserialize json into csharp object errors - Could not cast or convert from System.String to ProjectName.Models.CarsModel

I'm stuck with a tricky json. trying to deserialize below web api json into c# object. Seems like it has no key, only the below value. ["toyota","bmw","nissan","gmc&...
User456's user avatar
  • 103
0 votes
1 answer
2k views

From API response Cannot deserialize the current JSON object

I am getting this error when trying to deserialize data. the details are given below. ALso the screenshot of the running App in which i debugged the app and can see the data from my api response. My ...
Hotspot Shield's user avatar
0 votes
1 answer
2k views

Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value - ASP.NET

How to properly deserialize POST method "Update" while developing Telegram bot in ASP.NET Core Web API by using Telegram.Bot package? I used DeserializeObject(string) method to do so, but it ...
Anvarxon Xamzayev's user avatar

15 30 50 per page
1
2 3 4 5
40