I\'ve got the following IHttpModule
and I\'m trying to figure out how to execute an action from a controller for a given absolute or relative URL.
Something along the lines should do the job:
public void OnError(HttpContextBase context)
{
context.ClearError();
context.Response.StatusCode = 404;
var rd = new RouteData();
rd.Values["controller"] = "error";
rd.Values["action"] = "notfound";
IController controller = new ErrorController();
var rc = new RequestContext(context, rd);
controller.Execute(rc);
}
You might also find the following related answer useful.