Archives
-
ASP.NET MVC: Helper method to display date ranges
I have events web site where I want to show events start and end time to visitors. I wrote simple extension method called DisplayTimeRange() to display event time range on user-friendly manner. My goal is to show times as 01.01.2012 10:00 – 14:00 and 01.01.2012 15:00 – 01.03.2012 18:00. It’s practically displaying time ranges is shortest possible way. In this posting I will show you how to do it using extension method.
-
Windows Azure error: An unsupported response was received. The response header 'MSDeploy.Response' was '' but 'v1' was expected.
You may get the following error when deploying your web application from Visual Studio to Windows Azure using WebDeploy:
-
The selected database contains foreign keys that create a cycle
You may get the following error when creating data scripts with MSSQL 2008: The selected database contains foreign keys that create a cycle. Publishing data only is not supported for databases with cyclical foreign key relationships. This problem is caused by self-referencing tables and it is given even if you don’t export data from one of such tables. Here is simple and very dirty solution.
-
Deploying independent web applications to Windows Azure using single web role
I found very good blog post by Andy Cross’ Blog where he describes how to deploy multiple web sites in a single Windows Azure web role. I like the idea but there are some things that should be understood and done differently if you plan to use same web role for totally different web applications that you want to run on your Windows Azure instance. In this posting I will show you how to deploy independent web applications to Windows Azure instance using single web role.
-
ASP.NET security update shipping tomorrow
Out-of-band security update will be published for ASP.NET tomorrow. Security update will solve publicly known DoS issue that exists in all versions of ASP.NET. Update will be delivered through Windows Update and Windows Server Update. More details:
-
My next year TOP5 wishlist for Windows media, WP7 and XBox teams in Microsoft
After building up my home network where XBox streams media from Windows Home Server using Windows Media Center I was very happy with my solution. Over weeks and months of active consuming of my media I found a lot of things that need to be improved or fixed. I am still happy but sometimes I’m looking already for alternatives. Here is my TOP5 wishlist for Microsoft people who build consumer media products.
-
Connecting Windows Home Server to web through two routers
I wanted to get my Windows Home Server configured correctly for web so I have valid certificate by Microsoft and I can use subdomain service they are offering. As my home network is not default that is expected by Windows Home Server (no direct access to router that is connected to web) I had to trick my WHS a little bit. In this posting I will show you how to get Windows Home Server work with Microsoft address (http://something.homeserver.com) if it is not connected directly to router that has access to web.
-
MSSQL & NHibernate – mapping week numbers to properties
In one of my applications I have to use week numbers as properties of business classes that are persisted to database using NHibernate. Week numbers are used in UI and users can filter and sort data by week numbers. In this posting I will show you how to make SQL Server deal with week numbers and how to use them in your domain model.
-
Windows Azure Error: Failed to start Storage Emulator: the SQL Server instance ‘localhost\SQLExpress’ could not be found
When running some of your Windows Azure applications when storage emulator is not configured you may get the following error: "Windows Azure Tools: Failed to initialize Windows Azure storage emulator. Unable to start Development Storage. Failed to start Storage Emulator: the SQL Server instance ‘localhost\SQLExpress’ could not be found. Please configure the SQL Server instance for Storage Emulator using the ‘DSInit’ utility in the Windows Azure SDK.". Here’s how to solve this problem.
-
Making CopySourceAsHtml add-on work with VS2010
As there are still bloggers who use CopySourceAsHtml add-on for Visual Studio to get syntax highlighted code to their blog posts and there is no guidance in CSAH site how to make it work with Visual Studio 2010 I will give my guidance here. Almost all code in this blog is syntax highlighted by this add-on (read more from my post Visual Studio add-in: CopySourceAsHTML).
-
ASP.NET MVC: Simple view to display contents of DataTable
In one of my current projects I have to show reports based on SQL Server views. My code should be not aware of data it shows. It just asks data from view and displays it user. As WebGrid didn’t seem to work with DataTable (at least with no hocus-pocus) I wrote my own very simple view that shows contents of DataTable.
-
Using Lazy<T> and abstract wrapper class to lazy-load complex system parameters
.NET Framework 4.0 introduced new class called Lazy<T> and I wrote blog post about it: .Net Framework 4.0: Using System.Lazy<T>. One thing is annoying for me – we have to keep lazy loaded value and its value loader as separate things. In this posting I will introduce you my Lazy<T> wrapper for complex to get system parameters that uses template method to keep lazy value loader in parameter class.
-
Solution to Jira web service getWorklogs method error: Object of type System.Xml.XmlNode[] cannot be stored in an array of this type
When using Jira web service methods that operate on work logs you may get the following error when running your .NET application: Object of type System.Xml.XmlNode[] cannot be stored in an array of this type. In this posting I will show you solution to this problem.
-
ASP.NET MVC: Converting business objects to select list items
Some of our business classes are used to fill dropdown boxes or select lists. And often you have some base class for all your business classes. In this posting I will show you how to use base business class to write extension method that converts collection of business objects to ASP.NET MVC select list items without writing a lot of code.
-
ASP.NET 4.5 Preview: Using model binding to update data
My last posting about ASP.NET 4.5 introduced how to use strongly typed controls to display data. Using strongly typed presentation layer templates is not the only thing that model binding is good for. From ASP.NET MVC we know how convenient it is when model binders are also able to update our objects when they are modified. In this posting I will show you how to use strongly typed FormView to save data that user modified.
-
ASP.NET 4.5 Preview: Using model binding to display data
ASP.NET Forms 4.5 Preview introduces us model binding for web forms. Web developers who are familiar with ASP.NET MVC already know what model binding is and how powerful it is. Model binding means framework ability to construct objects of known types using values from presentation layer. In this posting I will show you how to use model binding with ASP.NET Forms 4.5.
-
ASP.NET MVC 4: Display modes
One new features of ASP.NET MVC 4 is support for display modes. This means that you can conditionally show different output to different user agents like desktop and mobile browsers. Of course, you can define your own custom rules too. In this posting I will show you how display modes work and explain how to use them in your ASP.NET MVC applications.
-
ASP.NET MVC 4: New mobile web application template
ASP.NET MVC 4 Developer Preview introduces also new template for mobile web applications. These templates are special because they are using jQuery Mobile – special jQuery library for building mobile user interfaces. In this posting I will show you how new mobile web application template looks like.
-
ASP.NET MVC 4: New template for web applications
I’m playing with ASP.NET MVC 4 Developer Preview. There is new default application template available for ASP.NET MVC 4 web applications. New template is modern, has better look than current one and has better support for different screen sizes. In this posting I will show you how new template looks like.
-
Using Lucene.NET search engine library in .NET applications
Adding search capabilities to applications is something that users often ask. Sometimes it is not enough to have just filters on lists. Instead of going with mainstream and write complex SQL queries we can be smarter and use specialized indexing and search solutions that perform way better than custom large SQL queries that I consider as anti-pattern for searching something. In this posting I will introduce you Lucene.NET indexing and search engine and show you how to use it in your applications.
-
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.
-
Importing issues from Jira to database using C#
I am evaluating hosted Jira Studio and it likes me more and more when I’m using it. As hosted service is not in our premises and contains important information about our work I was asked to find out if there’s a way how to read data from Jira Studio and save it to our local data store. In this posting I will show you a simple way how to read issues from Jira Studio and save them to database.
-
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.
-
DiscountASP–Winner of my daily WTF today
Today I tried to put up simple ASP.NET MVC application to DiscountASP shared hosting. It all started well but ended with most strange security and server architecture I’ve ever seen. I don’t want to insult them but it is really shocking and unexpected when some of top hosting providers just spits on web security.
-
MiniProfiler: Lightweight profiler for ASP.NET web applications
I found very cool small profiler that can also be used on production sites to quickly detect bottle necks in web application code. The profiler is called MiniProfiler and in this posting I will introduce you how to use it in your code.
-
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.
-
Using DebugView to catch debug output of .NET program
Often asked question: is there any way to gather debug output of .NET program that is running on environment where Visual Studio is not installed? Yes, you can do it and you can do it for free with program called DebugView. Here’s how it works.
-
dotPeek–JetBrains replaces .NET Reflector
Today I got e-mail from JetBrains stating that there is dotPeek early build available for download. dotPeek is .NET assemblies decompiler that is offered for free and that should replace .NET Reflector (not free anymore). dotPeek will also be part of ReSharper 6. In this posting I will give you brief introduction about dotPeek.
-
Using Advantage data providers to read DBF-files
In one of my projects I have to read FoxPro DBF-files and import data from them. As this code must run in server and customer doesn’t want to install FoxPro there we found another solution that seems at least to me way better. In this posting I will show you how to read DBF-files using Sybase Advantage data providers.
-
Timepicker–nice extension to jQuery UI Datepicker
jQuery UI Datepicker is popular dropdown calendar component. It is powerful, easy to use and one of my favorites for sure. Sometimes we need more than just picking dates. In one of my projects I needed something similar but instead of just dates I had dates and times. As I’m not strong on jQuery I looked for ready made component to get this functionality and then how I found Timepicker extension for jQuery UI Datepciker. Here’s how it looks and 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: Implementing CheckBoxList
My events site I’m building ASP.NET MVC got tags support for events. I implemented CheckBoxList helper method and tag updater method that I can use to update tags assigned to events. In this posting I will show you how to implement tags support using CheckBoxList helper in ASP.NET MVC.
-
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.
-
Dumping DataTable to debug window
Here’s one little method I use to write out debug information when investigating some new (legacy but new to me) system. Usually I remove this method later when I know how code works. It’s maybe not the best way to debug things but it works like charm in many situations.
-
Creating tag cloud using ASP.NET MVC and Entity Framework
I am building events site on ASP.NET MVC 3 and Entity Framework. Today I added tagging support to my site and created simple tag cloud. In this posting I will show you how my tag cloud is implemented. Feel free to use my code if you like it.
-
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.
-
ASP.NET MVC 3: Intranet Application template
ASP.NET MVC 3 Tools Update introduced new project template called Intranet Application. The main difference between internet and intranet application templates is the way how users are authenticated. In this posting I will talk about Intranet Application template and compare it to Internet Application template. Also I will give you references to guides that help you configure your intranet application.
-
ASP.NET MVC 3 Tools Updated released!
ASP.NET MVC 3 Tools Update is out and it introduces some new cool things. In this posting I will give you brief overview of new stuff available in ASP.NET MVC 3 Tools Update. More specific posts about new features will follow.
-
ASP.NET MVC: Using NonActionAttribute to restrict access to public methods of controller
Public non-action methods in ASP.NET MVC controllers are source of problems because they can be called by user when not handled carefully. Same time you may need public methods on controllers for some other reasons (some UI framework, testability problems, things you cannot change etc). In this posting I will show you how to handle controller methods properly.
-
Webcast: Brief introduction to Windows Identity Foundation
This is my first webcast on Windows Identity Foundation (WIF) and it will give you brief overview of this technology. I will tell you about how I found WIF, what is claims-based authentication, what tools are available and how you can use WIF in your systems. This is no-code overview and you can expect demos and code from my next WIF webcasts.
-
Book Review: Programming Windows Identity Foundation
Programming Windows Identity Foundation by Vittorio Bertocci is right now the only serious book about Windows Identity Foundation available.
-
ASP.NET: Building tree picker dialog using jQuery UI and TreeView control
Selecting things from dialogs and data represented as trees are very common things we see in business applications. In this posting I will show you how to use ASP.NET TreeView control and jQuery UI dialog component to build picker dialog that hosts tree data.
-
5 minutes WIF: Make your ASP.NET application use test-STS
Windows Identity Foundation (WIF) provides us with simple and dummy STS application we can use to develop our system with no actual STS in place. In this posting I will show you how to add STS support to your existing application and how to generate dummy application that plays you real STS.
-
Making WIF local STS to work with your ASP.NET application
Making Windows Identity Foundation (WIF) STS test application work with your solution is not as straightforward process as you can read from books and articles. There are some tricks and some configuration modifications you must do to get things work. Fortunately these steps are simple one.
-
Blogging locally and globally–my experience
In Baltic MVP Summit 2011 there was discussion about having two blogs - one for local and another for global audience – and how to publish once written information in these blogs. There are many ways how to optimize your blogging activities if you have more than one audience and here you can find my experiences, best practices and advices about this topic.
-
Book review: Peopleware: Productive Projects and Teams