Running a parallel foreach what makes calls to async methods is pretty straight forward, but what about if you want to synchronise thread access to a resource?That can be a bit tricky, so here is a solution with SemaphoreSlim:
When you are building an API, and doing all the right unit tests and ad-hoc tests and etc, the next type of test in the test pyramid is Integration Test of API Tests, as in you make HTTP calls to your API and inspect the result.
Simple website stress tool that uses Apache HTTP server benchmarking tool to get results for any request
Securing your MVC app is one of the tricky things when migrating, as an engineer, from classic ASP.NET to ASP.NET MVC.
By default, access is allowed to every controller and action of your web app, which is potentially unsafe. As an architect, I am sure you would like to enforce the security of your app and don’t rely on whether a developer will actually remember to add the [Authorize] attribute to a sensitive controller or action.
A few days ago I wanted to write to hosts, a HOSTS file in system32 used by Microsoft TCP/IP for Windows. Since this file is protected, you can edit it in administrative mode only. This means the user has to right click it and select “Run as administrator” for your project to run correctly. Fortunately there is a solution. The following code will request admin access from the user, and rerun it’s self in admin mode:
The solution I came up goes like this (in my project this code runs only once in every application boot by using HttpContext.Current.Cache)
Add a new Web Form to your project and name it js.aspx
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.
Since I couldn’t find a way to automate this (e.g. run it every night to backup schema of my server), I thought it would be a nice weekend project.
You can read more about it, or download project from https://github.com/georgekosmidis/mssql-schema-dump!
In shorthand, it goes like this:
This, will de-serialize your JSON string to a generic object, but going from this to get a value well within the structure of a JSON string is quite messy: