Include format in swagger generated from C# web api

I’ve been given a sample swagger definition and been asked to create a web-api to match. (I don’t have permissions to generate the API from SwaggerHub so that isnt’ an option). I need my Web API to generate Swagger docs as close to the original as possible. The existing Swagger doc includes schema definitions that… Read More Include format in swagger generated from C# web api

The tag helper 'form' must not have C# in the element's attribute declaration area

On a Razor Page I have: <form @{ if (Model.Topic is not null) { <text>x-init="data.topic=@Model.Topic"</text> } } method="post"> I want to render x-init="data.topic=@Model.Topic" only if Model.Topic has a value. I am getting the following error: The tag helper ‘form’ must not have C# in the element’s attribute declaration area. I tried a few options but… Read More The tag helper 'form' must not have C# in the element's attribute declaration area

ASP.NET Core WebAPI 6 cannot get value from configuration, how to fix?

I am trying migration source code of a ASP.NET Core 3.x to version 6.x . Source code https://www.c-sharpcorner.com/article/custome-jwt-token-and-asp-net-core-web-api//download/JWTTokenPOC.zip . Current project, I am using ASP.NET Core WebAPI 6 . My appsettings.json { /* The following identity settings need to be configured before the project can be successfully executed. For more info see https://aka.ms/dotnet-template-ms-identity-platform */ "AzureAd":… Read More ASP.NET Core WebAPI 6 cannot get value from configuration, how to fix?

DBContextBuilder doesnot contain a definition for UseSqlServer in .NET 6

I’m trying to implement microservices in .NET core framework (version 6.0) and facing this particular issue while adding the services of DBContext in the Program.CS file. statement I’m using : builder.Services.AddDbContext<ProductContext>(options=>options.UseSqlServer(builder.Configuration.GetConnectionString("ProductDB"))); Error CS1061 ‘DbContextOptionsBuilder’ does not contain a definition for ‘UseSqlServer’ and no accessible extension method ‘UseSqlServer’ accepting a first argument of type ‘DbContextOptionsBuilder’ could… Read More DBContextBuilder doesnot contain a definition for UseSqlServer in .NET 6

How to avoid dictionary override reference value of object when apply Dictionary.Clear()

I am working on .NET CORE 6. I have nested Dictionary<int, string> where I am adding value in loop to nested dictionary from string. The string holds multiple record where each record holds 15 columns hence dictionary is useful to hold keys. After 15 iteration, I add nested/ child dictionary to parent Dictionary<string, string> and… Read More How to avoid dictionary override reference value of object when apply Dictionary.Clear()

'Access-Control-Allow-Origin' in ASP.NET Core 6

Tested in Postman and works fine. In Browser I get this Error: Access to XMLHttpRequest at ‘http://localhost:5081/api/Accounting/GetSales&#8217; from origin ‘https://localhost:44426&#8217; has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Asp Net Core Project with Angular and .Net6 [DisableCors] [HttpGet("GetSales")] public IEnumerable<SaleDto> GetSales() { var result = _context.Sales.Select(x => new… Read More 'Access-Control-Allow-Origin' in ASP.NET Core 6