Is it possible for a ASPX view (in ASP.NET MVC) to have non-default constructor AND use this constructor when creating this view?
Example - Page will inherit from this class:
public class ViewPageWithHelper<TModel> : System.Web.Mvc.ViewPage<TModel> where TModel : class
{
public ViewPageWithHelper(Helpers helpers)
{
Helpers = helpers;
}
protected Helpers Helpers { get; private set; }
}
ASPX view:
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="MyInjectedViewPage<MyModel>" %>
<% Helpers.XXXX %>
Now, I'd like to inject Helpers into view somehow - automatically. Ideas?