ASP.NET MVC: An Error has occured when trying to create a controller
Posted
by Grayson Mitchell
on Stack Overflow
See other posts from Stack Overflow
or by Grayson Mitchell
Published on 2010-05-13T22:18:50Z
Indexed on
2010/05/13
22:24 UTC
Read the original article
Hit count: 1509
asp.net-mvc
I have got the following error a few times in my MVC applications, and have only managed to get past it by recreating my entire solution from scratch. The error message says make sure there is a paramaterless public constructor, but of course there is one. What else could this error refer to? (It looks like it can't find the controller at all)
Code where error occurs
public void Page_Load(object sender, System.EventArgs e)
{
// Change the current path so that the Routing handler can correctly interpret
// the request, then restore the original path so that the OutputCache module
// can correctly process the response (if caching is enabled).
string originalPath = Request.Path;
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
IHttpHandler httpHandler = new MvcHttpHandler();
**httpHandler.ProcessRequest(HttpContext.Current);**
HttpContext.Current.RewritePath(originalPath, false);
}
Error Message An error occurred when trying to create a controller of type 'Moe.Tactical.Ttas.Web.Controllers.TtasController'. Make sure that the controller has a parameterless public constructor.
© Stack Overflow or respective owner