Archive

Archive for September 2014

Honeypot implementation in MVC
Honeypot 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
Change Request.Form collection on the fly
How 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
Access auto property backing field with reflection
Access 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
Obtaining access token from Google+ API in non SPA web application
How 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
Same page language switching in Umbraco
Land 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
Bypass SSL certificate validation
A workaround quick solution when your SSL certificate expires
0
If you try to make a WebRequest to a server over https, you might run into the following exception. ... read more
Extension method equivalents in JavaScript
How 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
Filesize to proper display string
Display 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
The fastest way to export data to Excel
Export 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
Simple object mapper using reflection
Copy 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
Getting cropped image the smart way
The 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
Check whether you are getting cached content in MVC website
The 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
Single file deployment concept in ASP.NET with WebAPI
Deployment 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