Contents tagged with .Net Core
today I want to write a short description on how to add database context to IAuthorizationFilter.
Imagine that you have following filter:
public class HasApprovedFilter : Attribute, IAuthorizationFilter
private SomeDbContext _context;
public HasApprovedFilter(SomeDbContext context)
this._context = context;
public void OnAuthorization(AuthorizationFilterContext context)
var user = context.HttpContext.User;
var userAdd = _context.;
//var um = context.HttpContext.RequestServices.GetService();
} … more
today I want to make a short document about filters in .Net Core.
There are by default four types of filters:
Filters that implement IAuthorizationFilter which allow us to implement OnAuthorization method which allow us to add custom security logic.
Filters that implement IActionFilter has two methods: OnActionExecuting, OnActionExecuted. Those two methods executed before and after action executing.
Filters that implement IExceptionFilter has method OnException, which allows to handle exceptions.
Filters that implement IResultFilter has two methods: OnResultExecuting, OnResultExecuted.
Filters can be applied at controller or at action level. That gives following … more
today I want to describe some .Net core tag helpers that you can use in order to create your web pages. There are plenty of already implemented tag helpers that can simplify your life as a developer.
Here is the list of already made:
It is not a complete list, but I suppose those 16 elements help you to grasp how wide it's functionality.
Anchor Tag Helper
Consider following declaration:
<a asp-controller='Presenter' asp-action='Presentation' asp-route-id=@Model.PresenterID>Presenter ID: @Model.PresenterID</a> … more
today I want to describe some basic steps that you can use in order to create and apply migrations to your code.
So, let's start.
Imagine that in your .Net Core project you made some changes and would like them to be created in a form of C# code migration. How to do this in package manager console? Below are steps that I've applied:
1. add-migration "identity"
Enjoy with results. The first command will create for your C# code that will describe which tables need to be created. Second command will execute that C# code and will create on your db them.
today I want to write few words about different kinds of Views in .Net core.
So, if you decide somehow to create new view you can see something like this:
and now question. What is the difference between MVC View Page, MVC View Layout Page, MVC View Start Page and MVC View Imports page?
So, if to draw the lines then following can be said.
MVC View Page is fitting for displaying different models.
MVC View Layout Page is inteded as View that has @RenderBody() statement. RenderBody will be placeholder where MVC View Page will be rendered.
MVC View Start Page is used as mediator between MVC View Page and MVC View Layout page.
The last puzzling view is MVC View … more