
Image from Pexels
Tagged articles - ASP.NET Core
Found 58 articles tagged with ASP.NET Core
05
May
2022
Protecting static files in ASP.NET Core using custom middleware
.NET229 titlesRestricting access to specific static content with middleware in ASP.NET Core
0
The most common scenario for static files is just to serve them as they are without any additional hassle or access rules.To serve static content which are often just images, css, javascript or other common static web content, you just need to involve static content middleware in your ASP.NET core application pipeline.
Adding static content in ASP.NET Core applications is as simple as adding wwwroot folder to root of your web application and adding StaticFiles middleware to your pipeline. By default these files will become publicly available, but in the further text we'll deal with how restrict access to these static files you have in your application.
...read more
20
Dec
2021
Supporting multiple authentication schemes in asp.net core webapi
.NET229 titlesUsing more than one authentication schemes in webapi projects
0
Is is not so often than you have to use more than one authentication schemes in your project, but there are some corner cases when you have to do so. One of it is a scenario where you are supporting some weaker authentication schema like basic http authentication where credentials are supplied pretty much on every request.
This kind of loosen security schema is to some limited extend suitable for internal APIs meaning that no other than users or most likely application within your organization network will access...read more
25
May
2021
Using interceptors with dependency injection in Entity Framework Core
.NET229 titlesEF Core interceptors via dependency injection in ASP.NET 5
0
I while ago I wrote an article on how to Access multiple databases from the same DbContext in EF Core which relies on interceptors to mutate the SQL query diring execution. This code works just fine and it updates the command prior to it's execution, but it lacks in option to inject registered services to it's constructor as i used new keyword to initialize class instances.
Adding interceptor without dependency injection
...read more
08
May
2021
Implementing soft delete in EF Core using triggers
.NET229 titlesEntity soft delete implementation in EF Core
0
Implementation approach for soft delete is more-less straight forward thing. Instead of deleting data record, you introduce a flag which will mark the record as deleted and you can simply filter out on it and not show the data with the flag set. This way you do not loose data, but you restrict the end user to see it.
This way of "deleting" data records, or better said marking them as deleted applies for certain types of applications, but sometime this requirement may come later as a new feature while the actual delete is in place...read more
24
Apr
2021
Handling file upload in ASP.NET Core 5 with Swagger UI
.NET 229 titlesGenerating proper file upload in Swagger UI for file upload in ASP.NET Core 5
0
In 2019 I worked on a REST API service which accepts files and stores them. Back then in .NET Core 2.2 I wrote custom Swagger operation filter which I described in article Handling file uploads in Swagger UI with ASP.NET Core...read more
26
Mar
2021
Generic type controller methods in ASP.NET Core
.NET229 titlesUsing generic type controller methods in ASP.NET Core with Swagger
0
Generic types are great way to re-use methods and apply the same logic to different types. However, they come with some limitations, especially in ASP.NET realm...read more
17
Jan
2021
Mocking view mapped DbSets with XUnit in EF Core
.NET229 titlesWriting unit tests for view bounded entities in EF Core
0
Using in-memory DbContext is a great way to mock your actual DbContext in unit tests. You basically initialize the instance of your DbContext and seed some random data before you assert the result of your repository method...read more
19
Dec
2020
Setting up SQL Server IDistributedCache with migration in ASP.NET Core
.NET229 titlesEmbedding SQL Server caching in a project with EFCore migration
0
Caching data using Microsoft SQL Server may not be the most popular way of caching data because of the performance comparing to caching data to Redis, but it is maybe the most convenient way to keep your state of the application outside the process itself. Beside, if you are already using SQL Server database, you can just move the caching infrastructure to a separate schema inside the same database and keep using it until requirements are met for cache storage of better performance (like Redis for example).
This makes infrastructure not so complex and less dependent, again until the requirements for something faster are met.
...read more
11
Dec
2020
Representing available string values for parameters as list in Swagger ASP.NET Core
.NET229 titlesValid values as list in Swagger UI in ASP.NET Core
0
Swagger is a great way do describe your RESTful API. In ASP.NET it is pretty easy to wire up your OpenAPI documentation with your service facade with Swashbuckle NuGet package...read more
24
Nov
2020
Running multiple queries at the same time in EF Core
.NET229 titlesOvercoming the limitation of EF Core query execution
0
Since the time of ADO in .NET one of the limitations was that one connection can execute single command at the time. Same limitation Entity Framework inherited and you can execute single command at the time per instance of your DbContext...read more
17
Nov
2020
Accessing multiple databases from the same DbContext in EF Core
.NET229 titlesMultiple database access from the same DbContext in Entity Framework Core 5
0
It is not uncommon to have a requirement to access tables or views in different databases in the same query. In order to be able to do your joins on tables or views in different databases you need to do it in the same connection instance which is bound to DbContext, therefore this access as to be accomplished from the same DbContext instance...read more
06
Sep
2020
Seeding data in EF Core using SQL scripts
.NET229 titlesAnother way of seeding data in EF Core
0
Not so while ago I wrote an article on Seeding data with Entity Framework Core using migrations. This approach relies on EF Core migrations to ensure seeding of specific data is done only once using __EFMigrationsHistory table to track structural migrations as well as data seeding migrations.
In large number of cases this approach works just fine and you do not need to do any adjustments or add any additional tables, just use migrations mechanism out of the box...read more
30
Jul
2020
Basic authentication with Swagger and ASP.NET Core
.NET229 titlesSetting up basic authentication in ASP.NET Core Web API projects
0
Basic authentication is not so popular authentication method nowadays. There is a valid reason for that and that is mainly the way credentials are used to authenticate to access the resources...read more
21
Jul
2020
Seeding data with Entity Framework Core using migrations
.NET229 titlesUsing EF Core migrations to seed the data
0
As much as it is important for testing the functionality of the application, data seeding can also be used to pre-load some values like lookups not only to development and test environment but also to populate these values in production as well.
Seeding of data can be done in several ways and in this article I will go through two ways of seeding data. Both of them have their pros and cons and it is up to you to pick the way you want to have your data pre-seeded in your application database.
...read more
21
Jun
2020
Dealing with default API versions in Swagger UI
.NET229 titlesFixing additional routes in Swagger API when using default versions
0
Having your REST API versioned is important for evolving of the service over time. Especially if your service is exposed t multiple 3rd party clients...read more
.NET
5
Jun
2022
Using dotnet nuget package vulnerability scan in Azure DevOps build
Listing nuget vulnerabilities and controlling build in Azure DevOps
5
May
2022
Protecting static files in ASP.NET Core using custom middleware
Restricting access to specific static content with middleware in ASP.NET Core
20
Dec
2021
Supporting multiple authentication schemes in asp.net core webapi
Using more than one authentication schemes in webapi projects
12
Dec
2021
Controlling the flow of migrations in EF Core
Altering EF Core migrations execution order
28
Nov
2021
Unit of work pattern with Dapper
Implementing unit of work pattern with Dapper in .NET 5
21
Sep
2021
Adding display name to Enum values
Implementing additional values for Enum items in C#
JavaScript
28
Oct
2018
HTML5 localStorage with expiry with vanilla JavaScript
Using HTML5 localStorage with expiry
8
May
2018
Monitoring DOM changes with JavaScript
Handling DOM changes with plain JavaScript
9
May
2017
Non blocking CSS load on the page
Load external CSS files in an async manner
16
Mar
2017
Serialize html form to JSON without using JQuery
Transform user input from HTML form fields to JSON
17
Jan
2016
Copy text value to clipboard using jQuery
Simple sample of using jQuery to copy value to clipboard
11
Jan
2016
Resize image on the client side with JQuery
Reducing the upload sie by resizing image on the client side
SQL/T-SQL
22
Feb
2022
Select column names with values from SQL Server database
Fetching column names with its value in T-SQL using built in JSON methods
23
May
2020
Identifying opened connections for the specific application in SQL Server
Connection listing queries in SQL Server
3
May
2018
Reading JSON data in T-SQL on SQL Server
Extracting values from JSON string on SQL Server using T-SQL
28
Apr
2016
Create XML/HTML with T-SQL
Generating XML/HTML output in SQL Server
24
Nov
2015
IP address to octets split in TSQL
Split IP addresse into octets in SQL Server
20
Jul
2015
Getting first and last second of the current year, month and day
Using minimum and maximum date time in SQL query
Umbraco CMS
2
Mar
2018
Minify HTML output of your pages
Minification of HTML output using ASP.NET IHttpModule
18
Apr
2015
Generate sitemap.xml on the fly in Umbraco CMS
Simple sitemap.xml Umbraco handler
2
Mar
2015
Accessing UmbracoHelper in HttpHandler request
Working with UmbracoHelper and IPublishedContent in HttpHandler
14
Sep
2014
Same page language switching in Umbraco
Land on the same page in different language in Umbraco using Relations
4
Sep
2014
Getting cropped image the smart way
The way to get cropped image URL with option to load original image too
27
Aug
2014
Fastest way to return JSON result from a controller
Resturn JSON in MVC controller action