Sunday, June 9, 2024
Serilog Sinks
Sunday, May 26, 2024
Use case of .http files in Visual Studio
An API .http file a feature provided by Visual Studio 2022 for testing ASP.NET Core projects. This serves as a convenient way to send HTTP requests and view responses directly within the Visual Studio IDE.
Further more, the VS 2022 .http file editor allows you to define HTTP requests that you want to send to test API endpoints.
It comes with an easy way to specify the details of HTTP requests including
- URL
- HTTP method (GET, POST, PUT.,DELETE)
- headers,
- query parameters
- request body
After completion of the a request, Visual Studio IDE displays the response directly within the editor itself, allowing an easy way to view the response status code, headers, and body.
To learn mor visit this link.
Cheers,
Samitha
Saturday, April 20, 2024
ASP.NET Web Applications with Content Security Policy
Content Security Policy (CSP) can be used to protect any ASP.NET web application by identifying
- Cross-site Scripting (XSS) attacks
- SQL or data injection attacks.
Cheers,
Samitha
Monday, April 8, 2024
.Net core 6 db migration error
I got following error when trying to run the migrations on a .NET Core 6 Web API.
Unable to create an object of type 'MyDBContext'
After tarting out different approaches following changes made migrations work.
1. MyDbContext
public class MyDbContext : DbContext, IMyDbContext
{
public MyDbContext()
{
}
public MyDbContext(DbContextOptions<MyDbContext> options) : base(options)
{
protected override void OnConfiguring(DbContextOptionsBuilder
optionsBuilder)
{
optionsBuilder.UseSqlServer("Data Source=localhost;Initial Catalog = Library;Integrated Security=True;Trusted_Connection=True;TrustServerCertificate=True");
}
//...more code
}
2. Program.cs
builder.Services.ConfigureLoggerService();
//more options
options.UseSqlServer(builder.Configuration.GetConnectionString
("DefaultConnection")));
Cheers,
Samitha