ASP.NET
Using Moq to mock ASP.NET MVC HttpContextBase
Here’s my little example about how to use Moq to mock HttpContextBase and it’s members to make controller tests pass. You can use this code when you are not allowed to use open-source or use-on-your-own-risk pieces of software that provide you this kind on initialization using built-in features. Also it is good exercise that introduces you how to solve mocking problems.
ASP.NET MVC: Moving code from controller action to service layer
I fixed one controller action in my application that doesn’t seemed good enough for me. It wasn’t big move I did but worth to show to beginners how nice code you can write when using correct layering in your application. As an example I use code from my posting ASP.NET MVC: How to implement invitation codes support.
ASP.NET MVC: Showing dates using DayCalendarPage extension method
In my events web site I need to show event dates in lists so users can easily see them. I decided to use day calendar view like shown on image on left. As there are more than one view where I need this functionality I wrote HTML extension method that outputs day calendar view based on current date. In this posting I will show you my extension method and show you how to use it.
ASP.NET MVC: Getting selected values from CheckBoxList
In my last posting I introduced how to implement CheckBoxList in ASP.NET MVC. Showing checkbox list is one part of the story. When user saves the form then we have to update also data that was represented by CheckBoxList. In this posting I will show you how to update event tags collection when user saves event.
ASP.NET MVC: How to implement invitation codes support
Last Christmas I blogged about how to make ASP.NET MVC users authorized only if they have profiles created. This works well on public sites where everybody can be user. Sometimes we don’t want to let all users to our system even when they were correctly authenticated by some authentication service. In this blog post I will show you how to create authorization attribute that you can use to make authenticated users insert their access code if it is their first visit to site.
ASP.NET MVC 3: Using controllers scaffolding
ASP.NET MVC 3 Tools Update introduces support for controllers scaffolding with views and data access code. Right now I am building one very simple web site for free tech events and as I am building it on ASP.NET MVC 3 I have good testing polygon right here. In this posting I will show you how controller scaffolding works and what is the end result.
ASP.NET MVC: Defining short URL-s for root level pages
Short URL-s are more and more important part of page usability as mobile internet is growing. Long URL-s are not convenient to type due to small keyboards and screens of mobile devices. Also short URL-s are easier to remember and using well chosen short URL-s your pages may also get better rankings in search engines indexes. In this posting I will show you how to create short URL-s for ASP.NET MVC pages. (more…)