Archived articles - September 2014
Archive for September 2014 (13)
22
Sep
2014
Honeypot implementation in ASP.NET MVC
.NET229 titlesHoneypot bot detection implementation in MVC
0
You can find a bunch of articles on internet about HONEYPOT implementation on web pages, but in short it is a replacement for CAPTCHA anti-bot security. In CAPTCHA scenario, user needs to enter hardly recognizable characters in order to prove that he is not a bot trying to submit data...read more
18
Sep
2014
Change Request.Form collection on the fly
.NET229 titlesHow to modify Request.Form collection
0
Data from form are sent to backend (whether code behing of page in WebForms or Controller Action in MVC) in Request.Form property.
It is oragnized as collection of name and value and can be easily access by name. In some extreme cases, you need to make some modifications to posted form data.
...read more
18
Sep
2014
Access auto property backing field with reflection
.NET229 titlesAccess property fields of auto property in C#
0
Using reflection you can easily access any property, filed, methods, pretty much anything of any type in .NET. Reflection is never the most elegant way to do something, but sometime you just have to do it.
In older versions of C#, to declare a simple property in a class you would have to declare a private field which will be exposed by the property outside the class
...read more
17
Sep
2014
Obtaining access token from Google+ API in non SPA web application
.NET229 titlesHow to get access token in C# backend from Google+ API
0
Recently I was trying to use Google+ OAuth api for authenticating with Google+ and fetch some user basic info such as name and email.
...read more
14
Sep
2014
Same page language switching in Umbraco
Umbraco CMS25 titlesLand on the same page in different language in Umbraco using Relations
0
When we build multi-language website, we usually create two root elements which represent different language websites.
To switch the language you just need to add a link to other root elements which represent other languages of the website. With this approach, when you switch language you will end up at homepage of the language regardless which page you were viewing.
...read more
13
Sep
2014
Bypass SSL certificate validation
.NET229 titlesA workaround quick solution when your SSL certificate expires
0
It is a common thing that some of your application functionalities depend on an external HTTPS endpoint. However, renewal of SSL certificate for the external party is out of your control and you have to rely on the third party that certificate will be renewed on time...read more
11
Sep
2014
Extension method equivalents in JavaScript
JavaScript31 titlesHow to write an extension method for a type in JavaScript
0
For someone who works in C#, extension methods are one really useful feature introduced in .NET framework.
I use extension methods a lot because they are so nicely integrated with intellisense and you can access them really easy.
...read more
09
Sep
2014
Filesize to proper display string
.NET229 titlesDisplay size of file in the proper maner
0
How many times you had to display file size on your web page? Pretty much every time you might have the same issue with recalculating size to KB or MB.
I caught myself doing this for so many times over and over, so finally I decided to write a piece of code for that.
...read more
08
Sep
2014
The fastest way to export data to Excel
.NET229 titlesExport data to Excel in ASP.NET C#
0
It is not so rare that you have to provide some sort of export of your data stored in database. I have a feeling that clients really like to have that functionality, probably because they are more comfortable with Excel than with any other tool.
First thing that might pop to your mind is to add a reference to Office library, but that would require that you have Office on the hosting machine which might not be the case as most of hosts do not have it.
...read more
06
Sep
2014
Simple object mapper using reflection
.NET229 titlesCopy property values from one object to another using reflection
0
Dealing with models and POCO classes in MVC sometimes require to map properties from one object to another because they have some properties of the same name and type.
This also can be a case when you are loading a model class from some other source and you need to transform it to your type with some additional properties, but also a bunch of properties with values from the source object instance.
...read more
04
Sep
2014
Getting cropped image the smart way
Umbraco CMS25 titlesThe way to get cropped image URL with option to load original image too
0
I noticed that some of the content managers keep complaining about the quality and size of cropped images. If you lower down quality, file is smaller but in some cases it gets blurry with quirks which comes from compression applied to a file.
Let's face it, image cropper is not Photoshop with all options for image optimization...read more
03
Sep
2014
Check whether you are getting cached content in MVC website
.NET229 titlesThe ways to check whether you are viewing cached or most recent content
0
It happens from time to time that you publish some content from back-end, but on the website you still see the old content.
Reasons for this may be different:
...read more
03
Sep
2014
Single file deployment concept in ASP.NET with WebAPI
.NET229 titlesDeployment contained in single file using WebAPI
0
As much as this sound new to you, it actually isn't.
If you worked on any Windows From application in .NET you had an option to embedded files in your form like images, icons and even sounds and videos. This made deployment a lot easier because you only have to deploy one .exe file.
...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