How to render an ASP.NET MVC view as a string?

Here’s what I came up with, and it’s working for me. I added the following method(s) to my controller base class. (You can always make these static methods somewhere else that accept a controller as a parameter I suppose) MVC2 .ascx style protected string RenderViewToString<T>(string viewPath, T model) { ViewData.Model = model; using (var writer … Read more

How to fix: Handler “PageHandlerFactory-Integrated” has a bad module “ManagedPipelineHandler” in its module list

It turns out that this is because ASP.Net was not completely installed with IIS even though I checked that box in the “Add Feature” dialog. To fix this, I simply ran the following command at the command prompt %windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -i If I had been on a 32 bit system, it would have looked like the … Read more

Visual Studio debugging/loading very slow

Here is how I solved the “slow symbol loading” problem in Visual Studio 2012: Go to Tools -> Options -> Debugging -> General CHECK the checkmark next to “Enable Just My Code”. Go to Tools -> Options -> Debugging -> Symbols Click on the “…” button and create/select a new folder somewhere on your local … Read more

How to get ELMAH to work with ASP.NET MVC [HandleError] attribute?

You can subclass HandleErrorAttribute and override its OnException member (no need to copy) so that it logs the exception with ELMAH and only if the base implementation handles it. The minimal amount of code you need is as follows: using System.Web.Mvc; using Elmah; public class HandleErrorAttribute : System.Web.Mvc.HandleErrorAttribute { public override void OnException(ExceptionContext context) { … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)