Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
0 answers
170 views

Logger Not writing logs to the Log Files in .NET 5 Web API when deployed on IIS locally

I want to deploy a .NET 5 Web API project to my local IIS. The project includes a Logger.cs file, which writes exception messages caught in controller methods to a text file located in the root of the ...
BOO1's user avatar
  • 1
2 votes
1 answer
1k views

.net5 => Could not load file or assembly System.Runtime, Version=6.0.0.0

I have a solution with several WebAPI projects. All projects worked as needed, nothing changed in code. But one Monday (yesterday) I turned on my computer and tried to debug one of the project, which ...
Dimitry's user avatar
  • 287
0 votes
1 answer
2k views

C# Web API with Scope Specific Routes

I am utilizing IdentityServer4 as the identity provider and my C# Web API (for Users) is protected via: services.AddAuthentication(Authentication.Bearer) .AddJwtBearer(Authentication.Bearer, options ...
ScubaSteve's user avatar
  • 8,250
0 votes
2 answers
4k views

How to create consistent API response class in ASP.NET Core 5 Web API

How would I create a consistent generic API response class in ASP.NET Core 5 Web API. Basically I want to have a response from API just like { Status Code : 200 or 404 Result Count : 1 (null ...
Nilesh's user avatar
  • 608
0 votes
1 answer
607 views

Can't return multiple object on asp.net core web api

I can't return an integer and an IEnumerable from my Web API. IEnumerable has vm classes. This is Response.cs: using System.Collections.Generic; using TheMPDB_API.DataClasses; namespace TheMPDB_API....
TheKralGame's user avatar
0 votes
2 answers
3k views

Confirm form resubmission - ASP.NET 5 MVC

I have two controllers Booking and Checkout. Posting form data from controller Booking to Checkout index get page. I want to retrieve the object submitted when clicking the back button from Checkout ...
Jbtf's user avatar
  • 111
0 votes
1 answer
532 views

How to achieve strictly file size limit in Abp

I'm trying to set strictly file size limit using filter, in the mean while, there is already a default global setting at Startup.cs Startup.cs int sizeLimit = 200000; services.Configure<...
Billy Chung's user avatar
1 vote
1 answer
886 views

FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer, Version=5.0.0.0 on IIS

I'm working on a microservices project based on .net 5 and recently add API versioning to the gateway endpoint (using Microsoft.AspNetCore.Mvc.Versioning and Microsoft.AspNetCore.Mvc.Versioning....
Sina Riani's user avatar
8 votes
1 answer
2k views

How to implement search in EF Core

I have a hiring management system app with 2 entities Person & Tag. Person can have a list of tags. This is my person entity: public int Id { get; set; } public string FirstName { get; set;...
moein vafapour's user avatar
0 votes
1 answer
4k views

Docker Reading File Paths c# net

I'm new to Docker and am having an issue with reading file paths using either client.DownloadFile(new Uri(inputData.FilePath), "test1.png"); to download the file or var fileBytes = await ...
user17218342's user avatar
1 vote
1 answer
360 views

Swagger - how attach an example to particular end-point

I'm working on API where my controllers just returns JsonDocument's instead of DTO's. I need to provide some response examples for API documentation. But examples should be dedicated for particular ...
WymyslonyNick's user avatar
24 votes
15 answers
84k views

System.InvalidOperationException: IDX20803: Unable to obtain configuration from: 'System.String' with .NET 5

I've been implementing IdentityServer4 to provide authorization for my React application. I have this working in my local dev environment, but am running into issues after deployed to IIS in Windows ...
Rayan's user avatar
  • 251
2 votes
1 answer
526 views

Migrate FormsAuthentication to .NET5.0

We have an ASP.NET MVC project running on .NET Framework 4.6.1, we use Forms authentication with cookies. We need to migrate this project to .NET 5.0, however Forms authentication is no longer ...
Rafael's user avatar
  • 1,213
6 votes
2 answers
13k views

Best way to implement the ProblemDetails in Asp.Net Core API in clean way

I need to use ProblemDetails for the validation errors. It's working as expected. But there is a big problem here, I have to write a similar code in all the action methods and I think it's not a good ...
Vivek Nuna's user avatar
0 votes
1 answer
1k views

Not Acceptable Response(406) Message Asp.NET Code Web API (C#) - .NET 5.0

Normally I use Ok() to return the 200OK message form a API controller. Also NotFound() and NoContent(). But I could not find something like Acceptable Response(406). So, my question is is it possible ...
Kevin Stephen Biswas's user avatar
0 votes
1 answer
2k views

Use multithreading in .net webapi

In my dot net core web api, I know the number of cpu thread available and the number of data to be processed. Lets say I have 8 threads for 800 data update request. How can I do something so that each ...
Frost's user avatar
  • 101
1 vote
1 answer
340 views

I have two models in .net5 api application with one to many relationship. child model contains IFormFile property. I cannot bind this property

Here are my models public class Category { public int Id { get; set; } public string Name { get; set; } public List<CategoryDetail> CategoryDetails { get; set; } } public class ...
Uttam Kar's user avatar
  • 323
1 vote
1 answer
252 views

Log<TState> never called on custom ILogger/ILogProvider implementation

I have implemented a custom logging system and everything seems to be working as expected, however, the Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<...
Shawn Lehner's user avatar
  • 1,323
0 votes
1 answer
1k views

Inject ILogger when registering HttpClient in Asp.Net Core 5.0

In Asp.Net Core when you register a custom service, like: services.AddScoped<ISomeService, SomeService>(); Then, out of the box you can access the Microsoft ILogger from the contractor of ...
osotorrio's user avatar
  • 1,140
1 vote
2 answers
2k views

How to migrate app.config settings used by an MSTest project to .NET 5

I'm migrating an ASP.NET Web API solution that uses the .NET Framework 4.6.1 to ASP.NET Core 5 / .NET Framework 5. Besides the Web API project there is an MSTest based testing project that shares the ...
ackh's user avatar
  • 2,012
0 votes
0 answers
69 views

restful web API .net5 console app cannot start in windows server 2016

I created an restful web api in .net5, I can run the console app after my built under bin\Debug\net5.0 and my console app starts like below; This is nice because IIS not needed, But when I transfer ...
Ali CAKIL's user avatar
  • 428
1 vote
0 answers
715 views

How to forward trace headers in responses with .Net 5 Web Api?

Is there a reason why distributed trace headers are not sent back in responses? Suppose a client makes a request like this: private static readonly AssemblyName AssemblyName = typeof(Program).Assembly....
Kasbolat Kumakhov's user avatar
1 vote
3 answers
7k views

403.18 - Forbidden The specified request cannot be processed in the application pool that is configured for this resource on the Web server

I don't understand why I get the error in the title of this post. I have a Website running its own Application Pool in .NET V4.0. Under the Website I have an Application running on its own Application ...
Sach K's user avatar
  • 713
1 vote
1 answer
1k views

UnauthorizedAccessException behavior in ASP.NET Core policy based authorization

I have a simple ASP.NET Core API (.net 5) application with security configured like this: services.AddControllers(options => options.Filters.Add(new MyExceptionFilter())); services....
UserControl's user avatar
  • 15.1k
1 vote
1 answer
138 views

How to create a GET route acting as a subscription route

I have a .Net 5 Web API and would like to create a GET endpoint (acting as a subscription) sending data every x seconds. I know that there are tools out there, e.g. SignalR, but I would like to know ...
Question3r's user avatar
  • 3,634
1 vote
1 answer
4k views

Test with postman get error 401 Unauthorized even if Azure AD Authentication is OK

I have created a web api in .NET 5 and then I published it on Azure. Here how I configured the web api in my startup: public void ConfigureServices(IServiceCollection services) { services....
Simone's user avatar
  • 2,420
3 votes
1 answer
823 views

.NET 5 Multiple projects in the same assembly

I have a solution with multiple projects inside. One of them are for a dashboard web application and one of them is for an API project. Is it possible to run these two application in the same assembly?...
Alper Alpdoğan's user avatar
0 votes
0 answers
134 views

.Net 5 Cron job: Cannot insert explicit value for identity column in table 'Tasks' when IDENTITY_INSERT is set to OFF

I have implemented a class who is responsible for making scheduled jobs using Cronos every 15 min Always when I run the application, The first time the code is executed everything is working fine, but ...
Ammar Ismaeel's user avatar
0 votes
0 answers
269 views

Data truncated and exception from XmlReader when reading Request body using StreamReader

I have a request that calls a post method. It is posting XML in the request content (but sending it as raw text). In testing, the length of the xml is 106880 characters. In the wep api post method, I ...
Jason's user avatar
  • 637
3 votes
2 answers
2k views

.NET Core API REST C# List into List is null

I'm developing an api in net core. I've done a post function in which I send an object containing multiple parameters and a list within another list. When I'm debugging the code the function is called ...
Geo's user avatar
  • 321
1 vote
2 answers
2k views

.NET 5 An error occurred while starting the application. DirectoryNotFoundException

I developed a Web API in C# using .NET 5, and it's working so well on my local machine, but on the server, it's not working. After using the detailed error, The error was that the Resources Folder ...
Ammar Ismaeel's user avatar
1 vote
1 answer
377 views

Why JSON return value has changed when migrating from .net core 3.1 to .net 5

I have an ASP.NET Web API that I have migrated from .NET Core 3.1 to .NET 5, it seems that the return values in my JSON have changed as a result of this. I've looked around but can't find anything as ...
RyanK's user avatar
  • 116
3 votes
0 answers
756 views

Return HttpResponseMessage in Net5 Api

I am in the process of updating a web api from netcore 2.2 to .net5 I have a lot of endpoints setup to create a new request to another endpoint and directly return that response [HttpGet] public async ...
Finlay Brown's user avatar
0 votes
1 answer
455 views

Throws an exception on a return while get another table data through foreign key in .NET 5 Web API

Doctor detail include into patient object in this method but it return a exception. [HttpGet("{id}", Name = "GetPatient")] public IActionResult Get(string id) { ...
Aaqil Ahmed's user avatar
2 votes
1 answer
539 views

Update an entity's property's values in the database whithin a repository query but before the query returns

I know my title sounds a little bit confusing but here's the better explanation: I have an API made with ASP.NET CORE and .NET 5 where I use the repository pattern to perform all my DB queries. For ...
Jimmy's user avatar
  • 135
0 votes
1 answer
505 views

asp net core kestrel high cpu usage

I Have some Web Api Applications in .Net5 + Kestrel, and I Want to test maximum request that can handles. When I increase the number of requests from low to high (for example, from 10 simultaneous ...
M.Saeed Palideh's user avatar
2 votes
2 answers
9k views

ASP.NET Core Upload Multiple File Web API model

I want to upload multiple files and used IFormFile to upload file using asp.net core 5 but the problem is it shows me string data type instead of the IFormFile. Can I just override the field ...
Alvin Quezon's user avatar
  • 1,201
2 votes
1 answer
2k views

Ignore [FromForm] data from rendering on swagger

I am working on .Net 5 Web API and I am using Swashbuckle, when I used [JsonIgnore] on my model it works fine for rendering my JSON Model : public partial class ApplicationDocument : BaseModel ...
esamaldin elzain's user avatar
2 votes
2 answers
2k views

How to trigger model validation inside IValidateOptions<T> implementation?

I have a .Net 5 app and want to add validators for my configurations. Given this sample options public sealed class DatabaseOptions { public string ConnectionString { get; set; } } I currently ...
Question3r's user avatar
  • 3,634
-1 votes
2 answers
301 views

Is there a way not to write cancellation token as a parameter to **each** controller action?

I have typical (I suppose) Web.API app targeting net.5: all controllers inherit from my own ApiControllerBase class ApiControllerBase initializes DbAccess class according to the particular child ...
ornic's user avatar
  • 382
0 votes
1 answer
69 views

Converting existing controller actions into Generic methods

In my ASP.NET 5 Web API project I find that many of my core controllers contain the exact same CRUD methods. I find that I'm simply copying/pasting the code and searching and replacing the main type. ...
WebDevGuy2's user avatar
  • 1,239
1 vote
1 answer
1k views

How to download big CSV files(about 250MB) while running on IIS10? Content-length=0

I have .net5.0 REST API hosted on IIS 10. I want to have a method to export data via CSV file. Code example: [HttpGet] [Route("download-file")] [ProducesResponseType(typeof(FileContentResult)...
Mikhail's user avatar
  • 11
2 votes
1 answer
1k views

.NET 5 Web API: Storing data per request

When getting a request in any action of any controller, I look at the jwt know which user is requesting and lookup the user in the database to get some user-data that I want to use throughout the ...
Michael Winther's user avatar
2 votes
0 answers
184 views

.NET 5, ASP.NET Blazor return DataAnnotation errors instead of JSON Parser Errors

Is there a way to get the DataAnnotation Errors rather than the JSON Parser Errors? I have a model. Relevant fields, for example, are: [RegularExpression(@"^(?i)(true|false)$", ErrorMessage =...
PirateQueen's user avatar
0 votes
1 answer
1k views

How to use ApplicationDbContext outside the controller in Asp .Net 5

I am using Asp .Net 5 to create a WebApi and I am trying to put all database operations in a separate class, the problem is I can't Use ApplicationDbContext by initiating a new object because it takes ...
esamaldin elzain's user avatar
3 votes
2 answers
4k views

Custom Validator for Enum in ASP.NET Core

public enum GroupBy { status = 0, dueDate = 1, requester = 2, assignee = 3 } I am using this enum in params of web api like this:- public async Task<IActionResult> Dashboard(...
Shashwat Prakash's user avatar
0 votes
3 answers
668 views

Deserialize json with data property to a list of objects to what is inside the json array

I try to deserealize it to return to javascript only the data property which is a list. My controller class which returns the json to javascript: public ActionResult<IEnumerable> GetCourseThemes(...
Misael Arreola's user avatar
0 votes
0 answers
36 views

Can I do a request from inside a WebAPI Controller (or BlazorComponent) using the current NTML context?

So currently I am inside of a controller, and I want to call another controller with HttpClient. But when I do, I get a 401: async Task MakePdf() { var client = HttpFactory.CreateClient(); ...
naspinski's user avatar
  • 34.6k
3 votes
3 answers
6k views

Enable CORS in ASP.Net Core 5 WebAPI

There are millions of articles and questions related to this issue and yet I cannot find what's wrong with my code. I have Startup, StartupProduction, and StartupDevelopment as the following. Also, I ...
Hamid Mayeli's user avatar
  • 1,088
1 vote
2 answers
677 views

Saving email to the directory with specified file name is not working in .NET 5.0

I am trying to follow the approach suggested in a post by Allan Eagle in code-project. This same approach was working fine up until .NET Core 3.1, but not with .NET 5.0 . Here is the save method I ...
BDB's user avatar
  • 459