Skip to main content

New answers tagged

0 votes

Swagger API not refreshing the documentation

In my case I didn't have the option enabled in the VS Mac to generate XML documentations for Release mode: simply go to the project properties and under Compiler tab, check the GENERATE XML ...
Dr TJ's user avatar
  • 3,349
0 votes

Trouble with ActionResult in unit test can't Assert.Equal on POST return value (asp.net core mvc web api)

I wrapped @shrinith-sanil answer into an extension to make it easy to reuse with all my controllers. Thanks! public static class ActionResultExtensions { /// <summary> /// Becuase ...
Nick Pirocanac's user avatar
0 votes

How to configure Swashbuckle to ignore property on model

Just remove { get;set; } for example if you dont want in request to be seen Id use it as field: public string Id; not as property: public string Id { get; set; }
mctr's user avatar
  • 51
0 votes

I am getting 400 Bad Request error on Post Request

Client side code/model sample and viewmodel used at controller samples may be better for exact problem. But it seems, this is a Model Binding problem. Are you sure jsonData is same json with POSTMAN ...
kanpinar's user avatar
  • 134
0 votes
Accepted

FastEndPoints swagger endpoint grouping name lower case issue

you have two options. 1.) the default behavior is to convert the group/tag names to title case. which can be changed like so: .SwaggerDocument(o => o.TagCase = TagCase.None); 2.) or you can ...
Dĵ ΝιΓΞΗΛψΚ's user avatar
0 votes

No type was found that matches the controller named 'help'

This answer does not apply directly to OPs question, but it does produce the same error Your controller's type name needs to end with the word 'Controller', case non-sensitive. https://learn.microsoft....
greg's user avatar
  • 1,853
3 votes
Accepted

MemoryCache SetSize, does it limit cache entry size

So it works little bit differently from what you expect. As stated in MS IMemoryCache docs, there's no measurement unit to handle cache size. So the developer (you) is responsible for handling all of ...
Michał Turczyn's user avatar
1 vote
Accepted

Data annotations not recognized by Entity Framework Core in one ASP.NET project but work properly in another

The resolution ended up being downgrading System.ComponentModel.Annotations from 5.0.0 to 4.7.0 in the problematic WebAPI project. All the attributes were recognized immediately.
Daniel's user avatar
  • 1,794
-1 votes

Couchbase Bootstrap Exception: UnsupportedAddressFamilyException with CCCP

That code looks like .NET SDK for Couchbase Server and not Couchbase Lite. If that's the case, it shouldn't be tagged as couchbase-lite. It also seems that is a very old version of the .NET SDK which ...
Vlad Velicu's user avatar
0 votes

Handling concurrent gift card purchases in ASP.NET Core API without causing database concurrency issues

One idea is to improve the selection process: // 2. Attempt to get an available activation code that hasn't been // used or expired, and isn't deleted. var getAvailableActivationCode = await ...
Theodor Zoulias's user avatar
0 votes

How to get only Odata.Count without value

You can use aggregate as in ?$filter=statecode eq 0&$apply=aggregate($count as Count) This will return only the count :)
Rasmus Christensen's user avatar
1 vote

Handling concurrent gift card purchases in ASP.NET Core API without causing database concurrency issues

The problem is transient, i.e. it should succeed on another attempt, so I would use Polly nuget package for retries. Define policy that would retry operation on DbUpdateConcurrencyException: private ...
Michał Turczyn's user avatar
0 votes

Can I provide callback from frontend (react) to backend and create API endpoint in react?

The "correct" way to do this from a HTTP standpoint is to return a HTTP 102 response from the endpoint until the ML processing is complete and the response delivered to that endpoint. ...
Rob Conklin's user avatar
  • 9,331
0 votes

How to block burp suite requests in an ASP.NET 4.8 Web API or ASP.NET Core Web API

You need read the request userAgent = Request.Headers["User-Agent"]; if (userAgent.Contains("Mozilla/5.0")) { // Request is likely from a browser } else { // Request is ...
Thirupathi cst's user avatar
0 votes

How to Handle Cold Starts for .NET API on Kubernetes?

an alternative to reduce the code start, is to think if you can ajust the IoC to using Lazy at injections, this can save some time on code start, but your app will need more processor time on each ...
pnoronha's user avatar
0 votes

TempData null in asp.net core

In my case I change my program.cs file and add this code : builder.Services.AddSession(options => { options.IdleTimeout = TimeSpan.FromMinutes(30); // Set your desired timeout options....
Mohammad Sadegh Mazaheri's user avatar
0 votes

Serilog format context property as top level property

An ExpressionTemplate can do this: // dotnet add package Serilog.Expressions Log.Logger = new LoggerConfiguration() .Enrich.WithProperty("Application", "Sample") .WriteTo....
Nicholas Blumhardt's user avatar
0 votes

Pass string array as data in jquery ajax to web api

from the question: How to pass an array as a querystring in a GET request by using JQuery AJAX answer: var uri = 'http://localhost:16629/api/AssassinApi/HireRocco', hitList = ['me', 'yourself']; $....
Aimeast's user avatar
  • 1,645
0 votes

Web API 2 return simple string without quotation mark when return type is IHttpActionResult

I know it's a bit late, but I had to work this out from this question and another answer. The OP's code works if a "text/plain" formatter is added to the Web API configuration, as shown in ...
sixeyes's user avatar
  • 561
0 votes

Web Api 2.2 with odata and $expand

Credit to @TYRONEMICHAEL for providing the correct answer. If you're using Microsoft.OData.Client, you won't alway be able to rely on expressions. This does NOT work in version 7.21.3: ...
Tangere Apps's user avatar
0 votes
Accepted

HTTPS disconnected - Kestrel

Ok, I think this came down to the service account not having permission to read the private key out of the certificate, which we fix with some magic PowerShell, which finds the certificate file and ...
EdH's user avatar
  • 541
0 votes

The 'Access-Control-Allow-Origin' header contains multiple values

In my case I wasn't setting the header anywhere in my code, but IIS was configured to add the header. I believe you go into IIS Manager, select your website and click HTTP Response Headers. You should ...
Jye's user avatar
  • 61
0 votes
Accepted

Serilog format context property as top level property

This can be achieve by create a custom JsonFormatter. When you use like .Enrich.FromLogContext() .WriteTo.Console(new JsonFormatter()) If you check the source code of JsonFormatter,then you ...
Qiang Fu's user avatar
  • 6,849
0 votes

CORS failed: The Same-Origin Policy disallows reading the remote resource

I found a solution, that worked for me. First I replaced this lines: var apiBaseUrl = builder.Configuration["ApiBaseUrl"] ?? "http://localhost:5000"; builder.Services.AddScoped(sp =...
r-kane's user avatar
  • 39
1 vote
Accepted

If I set AccessToken and RefreshToken both (JWT) as cookies by server, They both automatically will be sent to server in each request from client

I would keep both tokens in cookies to reduce token threats in the browser. Just give the refresh cookie a path like /refresh where that is a path that you use to rewrite cookies with new tokens. I ...
Gary Archer's user avatar
  • 28.5k
0 votes

How to add role parameter in my response body?

Update the Response Model: public class LoginResponse { public string TokenType { get; set; } public string AccessToken { get; set; } public int ExpiresIn { get; set; } public string ...
Amihai Joseph Torgeman's user avatar
-1 votes

Use httpclient in .net to send multiple requests without being blocked by timeout links

The following is the solution I found later. I am replying again now, hoping to help others. .NET has a real-time communication framework SignalR, which allows real-time communication between the ...
SBANAS's user avatar
  • 35
0 votes

Docker Debug from Visual Studio 2022 works and opens the Web API, but trying to run image from Powershell does not work, port not being listened

By default the :dev image produced by Visual Studio for debugging in the Debug configuration is not a full runnable image (see docs). That image relies on VS supplying volume mounts to use your ...
Nathan Carlson - MSFT's user avatar
2 votes
Accepted

ASP.NET Core 8.0 SignalR: Successful Connection but No Notifications Received in Client

SOLVED Issue I discovered a problem while working with SignalR in my NotificationHub. The issue was that clients were connecting to the hub, but they weren't receiving any notifications, even though I ...
Levan Amashukeli's user avatar
0 votes

Which base image to use when dockerizing an API based on .NET Framework 4.6.1?

You could start off one of the windows server images and install the specific version of msbuild from the dockerfile.
Jonathan's user avatar
  • 584
0 votes

ASP.NET webforms on .NET 4.8 with Web API : authentication issue - 401 Unauthorized error

Remove config.SuppressHostPrincipal(): This setting bypasses security for the entire application. Since web.config handles API access, it's unnecessary. Linux Clients: Linux clients won't have access ...
THE LIFE-TIME LEARNER's user avatar
1 vote
Accepted

The instance of entity type 'User' cannot be tracked because another instance with the same key value for 'Id' is already being tracked

In my case the error occurred because multiple instances of the same entity were being tracked by the Entity Framework context, causing a conflict. The issue was related to how related data was being ...
Arbross's user avatar
  • 55
1 vote
Accepted

StatusCode: 415, ReasonPhrase: 'Unsupported Media Type', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent

The issue you are facing stems from the fact that the ApiController convention assumes JSON by default when deserializing request bodies. Since you’re sending binary data with the application/octet-...
zupp's user avatar
  • 113
0 votes

Swagger UI Web Api documentation Present enums as strings?

A simple solution to add Description to the schema of enum with 2 one-liners. For this we need Schema Filter and to add schema filter to the startup, e.g. public class EnumSchemaFilter : ISchemaFilter ...
TPAKTOPA's user avatar
  • 2,602
0 votes

How can I prevent API returning response as gibberish data instead of JSON?

Because I had copied this into Postman from my browser, this included a lot of unnecessary headers and made the response come back gzipped or compressed. By turning off Accept Encoding Header it works ...
Markive's user avatar
  • 2,390
0 votes

How to Store users detail who made the changes in blazor server

Below are some suggestions based on my opinion you could consider achieving your requirement: 1)You could create a separate database for storing audit logs. you could set up scheduled archiving ...
Jalpa Panchal's user avatar

Top 50 recent answers are included