-1
[assembly: PreApplicationStartMethod(typeof(Mvc.Bootstrap.Datatables.Example.App_Start.RegisterDatatablesModelBinder), "Start")]

namespace Mvc.Bootstrap.Datatables.Example.App_Start
{
    public static class RegisterDatatablesModelBinder {
        public static void Start() {
            ModelBinders.Binders.Add(typeof(DataTablesParam), new NullableDataTablesModelBinder());
        }
    }
}

I found this in one of GitHub project can anyone tell me what this line does

[assembly: PreApplicationStartMethod(typeof(Mvc.Bootstrap.Datatables.Example.App_Start.RegisterDatatablesModelBinder), "Start")]

user5206903
  • 146
  • 1
  • 16
  • The names suggest that `RegisterDatatablesModelBinder.Start()` must be called after loading the library but before using any method from it, possible to register some itself as an event listener or similar. – SJuan76 Sep 17 '15 at 16:06
  • http://dailydotnettips.com/2011/08/27/initialize-assemblies-using-preapplicationstartmethodattribute-aspnet4-app/ " Assemblies supports a custom attribute called PreApplicationStartMethod which can be applied to any assembly that should be loaded to your ASP.NET application, and the ASP.NET engine will call the method you specify within it before actually running any of code defined in the application." --- So basically it's just telling the application to run `Start` before the 'actual' application starts, to my understanding – sab669 Sep 17 '15 at 16:06
  • Sets up an [assembly attribute](https://msdn.microsoft.com/en-us/library/4w8c1y2s%28v=vs.110%29.aspx). It tells application that this method of this class will be called on app start. More details [here](http://ilearnable.net/2010/11/22/webactivator-preapplicationstartmethod/) – Andrei Sep 17 '15 at 16:07
  • In fact, a quick google search would have answered that for you... feeling lazy today? – SJuan76 Sep 17 '15 at 16:08
  • @SJuan76 actually I was not aware what keyword to use for search – user5206903 Sep 17 '15 at 16:21

1 Answers1

1

It instructs the ASP.NET pipeline to call a specific method on a specific type, presumably (judging by its name) before application startup.

Jamiec
  • 133,658
  • 13
  • 134
  • 193