Posts

Converting an ASP.NET View to a String

Image
Sometimes you would like to get the contents of a view and store it in a string rather than render it as HTML. An example of this is if you want to compose HTML emails and you want to harness the power of the ASP.NET MVC infrastructure (which includes layouts, partial views, and models). In this post I will show you how to store rendered View content in a string.

Separating Business Rules from Data Access

Image
Business rules can be mixed into data access code. This scenario is a violation of the Single Responsibility Principle, because the data access class would have to change if the business rules change. In this post I will show you how to separate the business rules from the data access code.

Using NLog to Log to a Database with Entity Framework Code First

Image
NLog is a logging framework that is used to add logging capabilities to a .NET application. Today I am going to show how to use NLog to generate logs on a database created by Entity Framework Code First.

Adding an SQL Azure Linked Server

Image
When adding an SQL Azure Linked Server through SSMS, you will encounter an error if you go through the normal way (Server Objects > Linked Servers > New Linked Server). That is because the New Linked Server wizard does not allow you to specify the catalog name if the chosen Server Type is SQL Server, which should be chosen when adding an SQL Azure Linked Server. To accomplish this, the stored procedure sp_addlinkedserver should be used.

Login with AngularJS and ASP.NET Web API

Image
When creating a non-Web API ASP.NET MVC project using Individual Accounts, the generated template makes use of Forms Authentication. When logging in using Forms Authentication, a cookie is stored on the client's machine and that cookie is included by the browser in each future request.

Don't Make Me Think... About Your Code

Image
"Don't Make Me Think" is the title of the famous UX book by Steve Krug. One of the main ideas in the book is that a user interface should be designed in such a way that users' thinking is kept to a minimum. As much as possible, it should be obvious what actions the user must do to achieve a goal. Answers to questions like "where do I go to checkout?" or "what will happen when I click this button?" should be obvious just from looking at the page.

Entity Framework Code First Migrations

Image
So you've created your entities and had Entity Framework create your database for you. Now, you want to change your entities and of course also change the database schema. How do you go about doing that?