ASP.NET MVC 5: Custom authentication with OnActionExecuting
Although I prefer the AuthorizeAttribute approach, there is another simpler way with a base Controller and OnActionExecuting:
Let’s assume the following Controller:
ASP.NET MVC 5: Custom AuthorizeAttribute for custom authentication
In a previous post I wrote about how you
can should protect your web app from human errors by enforcing authentication by default.
ASP.NET MVC 5: “Authorization” by default for your web app
Securing your MVC app is a tricky business! Although security is a huge topic, one of the problems that you might encounter is that unauthenticated users are allowed by default to execute every action in your web app. This behaviour is potentially unsafe because you have to remember to decorate your actions with the authorize attribute each and every time, and humans are of course prone to errors!
C#: Basic Combinatorics
Basic combinatorics in C# is a straight forward task for relatively small numbers like (100!). This is a helper class I wrote when I was asked to write an online lottery system.
Keep in mind though, that for bigger numbers (above 100!) you will need Arbitrary-precision arithmetic.
Here is the code and please, if someone knows a faster way or has some suggestions let me now!
Export MS SQL Database schema with C#
A few days ago I was searching for a way to export MS SQL schema of all databases of a server for backup and migration purposes. Although I found some tools, what I needed was a way to get stored procedures, functions, views, triggers and everything even if it was encrypted.
C#: Calculating all Greek Public Holidays for any given year
After calculating the Greek Orthodox Easter, it was time for the public holidays calculation. With the Easter calculation ready, it proved to be much easier than expected!