Just Simply Code

Another developer blog

  • Home
  • About
  • Register
  • Policy

Year: 2016

Enum extension method to get value from Description attribute.

10 July 2016 / Leave a Comment

I’m going to show how to get the value from the Description attribute on each enum. We have the following enum as an example public enum MonthOfYear { [Description(“First month of the year”)] January, [Description(“Second month of the year”)] February, [Description(“Third month of the year”)] March // … and so on } If you use … [Read more…]

Posted in: Uncategorised Tagged: Enum, Extension Method

Adding SSL to WordPress site with CloudFlare

3 July 2016 / 2 Comments

I’ve been hearing a lot of good things about CloudFlare especially how they provide free SSL. CloudFlare is also great at protecting your sites from DDOS. They sit between your site and the users where all the traffic is routed through. This allows them to control which packets they reject and which ones go through. … [Read more…]

Posted in: Uncategorised Tagged: CloudFlare, SSL

Web request with RestSharp

25 June 2016 / 1 Comment

I recently have to build a little contact form that will post to an API. The application will need to firstly authenticate to the API with OAuth to get a token. It then uses that token to post the form to the API. The token will be valid for a number of seconds defined in the … [Read more…]

Posted in: Uncategorised Tagged: API, HTTP request, RestSharp

Redirected to incorrect log in URL in ASP.NET MVC

19 June 2016 / 4 Comments

When my team and I upgraded one of the projects from MVC 4 to MVC 5, we encountered an issue where users get redirected to the default log in URL Account/Login which is different to the one specified in the web.config in the authentication section. <authentication mode=”Forms”> <forms loginUrl=”~/Account/Security/Login”  timeout=”2880″ /> </authentication> After a bit of research on … [Read more…]

Posted in: Uncategorised Tagged: Authentication, MVC, Redirect

Dependencies injection in console application using Unity

28 March 2016 / 2 Comments

I’ve been building a little console app to be run as an Azure web job for my side project. I want to re-use some of the services in the business logic layer that serves the website this web job is for. This requires some dependencies injection in this console app. There is a Schedule service that … [Read more…]

Posted in: Uncategorised Tagged: Dependency Injection, Unity

“/” date separator

5 March 2016 / Leave a Comment

Last month after I installed Windows 10 on my computer at work, some of the UI tests started to fail because the date string on the UI did not match the expected date string. i.e. Date string on UI: 15-01-2016 Expected date string: 15/01/2016 The interesting thing was that in the code where it the date is … [Read more…]

Posted in: Uncategorised Tagged: Date, Formatting

No OWIN context found when upgrading MVC 4 to MVC 5

22 February 2016 / 4 Comments

One of the projects I’m working on is in MVC 4. The team decides to upgrade the project to MVC 5. The process is fairly simple. Go to Nuget Package Manager and upgrade MVC to MVC 5. The project then still builds successfully but when navigating to the site, I receive the following error.     … [Read more…]

Posted in: Uncategorised Tagged: MVC, OWIN, Upgrading

Validate uploaded image file in MVC 5 HttpPostedFileBase

6 February 2016 / Leave a Comment

A client wants to implement an image upload for user profiles last week. The file is validated when users upload for the right format and size. In MVC, the uploaded file is of the class HttpPostedFileBase. My solution is create a few extension methods for the class HttpPostedFileBase. These methods validate whether file is of an image format, … [Read more…]

Posted in: Uncategorised Tagged: File Upload, Image, MVC

Creating unique filtered index using code first in Entity Framework 6

30 January 2016 / Leave a Comment

I came across a requirement last week where users can associate additional email addresses to their account. Users will then have to confirm their additional email addresses. I added a new table in the database to accommodate this requirement. The table contains a PersonId column which is a foreign key to the Person table, an EmailAddress and EmailConfirmed … [Read more…]

Posted in: Uncategorised Tagged: Code First, Entity Framework 6

Integration testing for asynchronous methods

24 January 2016 / 1 Comment

I’m going to show how to perform integration test on an asynchronous method using Unit Test framework in Visual Studio 2015 using transaction scope. The idea is running each test method in a transaction scope and disposing it at the end of the test instead of completing the transaction. This will roll back any changes to … [Read more…]

Posted in: Uncategorised Tagged: Async, Testing
« Previous 1 2 3 Next »

Search Posts

Recent Posts

  • Override IHttpRequestBodyDetectionFeature.CanHaveBodyOverride value in .NET Core Web API
  • Allow empty request body in PUT and POST HTTP requests in .NET Core Web API
  • Modify request body with middleware in .NET Core Web API
  • Running MS Orleans on AWS ECS
  • Respect leading and trailing spaces when querying SQL Server
Support my blog here!Support my blog!

Archives

  • July 2024
  • June 2024
  • July 2023
  • April 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
  • January 2021
  • December 2020
  • November 2020
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • July 2019
  • June 2019
  • May 2019
  • April 2019
  • March 2019
  • February 2019
  • January 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • June 2018
  • May 2018
  • October 2017
  • September 2017
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • March 2017
  • February 2017
  • January 2017
  • December 2016
  • November 2016
  • October 2016
  • September 2016
  • July 2016
  • June 2016
  • March 2016
  • February 2016
  • January 2016

Copyright © 2026 Just Simply Code.

Me WordPress Theme by themehall.com