ASP.NET MVC 3: Creating HttpStatusCodeResult with view based body

My last posts described new action results in ASP.NET MVC 3 – HttpNotFoundResult and HttpStatusCodeResult. Unfortunately these result have no body to send to client but there are times we need it to inform our visitor about problems the way that we don’t go out of information context where visitor is. In this example I will show you how to write your own HttpStatusCodeResult that has also body.

Read more

ASP.NET MVC 3: Using HttpStatusCodeResult

ASP.NET MVC 3 also introduces new action result HttpStatusCodeResult. This action result provides you way how to specify HTTP status code and status description in your controllers. In this posting I will show you how to use HttpStatusCodeResult in your real-world applications providing meaningful status code for products that were online once but are now gone and we don’t expect them to be back in future.

Read more

Using ExcelPackage to create Excel sheets on server

In one of my community projects I needed to output some listings as Excel file. As installing Excel to server is non-sense that I was easily able to avoid I found simple solution for Excel 2007 files – open-source project called ExcelPackage. In this posting I will show you hot to create simple event attendees report in Excel 2007 format using ExcelPackage.

Read more

How to avoid the exception “Substitution controls cannot be used in cached User Controls or cached Master Pages.”

Recently I wrote example about using user controls with donut caching. Because cache substitutions are not allowed inside partially cached controls you may get the errorSubstitution controls cannot be used in cached User Controls or cached Master Pages when breaking this rule. In this posting I will introduce some strategies that help to avoid this error.

Read more