Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
Если брать манифест в файлике, то вы еще до загрузки сборки можете проверить, например, совместимость версий
Еще классно можно подцепить модули в виде Nuget пакетов ;)
namespace HomePlugin.Controllers
{
public class HomeController : Controller
{
[Route(""), HttpGet]
public ActionResult Index()
{
return View();
}
}
}
[assembly: WebActivatorEx.PostApplicationStartMethod(typeof(RouteConfig), "RegisterRoutes")]
namespace HomePlugin.App_Start
{
public class RouteConfig
{
public static void RegisterRoutes()
{
RouteCollection routes = RouteTable.Routes;
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapMvcAttributeRoutes();
}
}
}
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5.1">
<assemblies>
<add assembly="HomePlugin"/>
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5.1" />
</system.web>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin\HomePlugin\bin;" />
</assemblyBinding>
</runtime>
</configuration>
[assembly: WebActivatorEx.PostApplicationStartMethod(typeof(RegisterViewEngine), "Start")]
namespace WebAndPlug.App_Start
{
public static class RegisterViewEngine
{
public static void Start()
{
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new PluginViewEngine());
}
}
public class PluginViewEngine : RazorViewEngine
{
#region Overrides of VirtualPathProviderViewEngine
public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache)
{
var ctrlAssembly = controllerContext.Controller.GetType().Assembly.GetName().Name;
string controller = controllerContext.RouteData.GetRequiredString("controller");
string action = controllerContext.RouteData.GetRequiredString("action");
viewName = "~/bin/" + ctrlAssembly + "/Views/" + controller + "/" + viewName + ".cshtml";
return base.FindView(controllerContext, viewName, masterName, useCache);
}
public override ViewEngineResult FindPartialView(ControllerContext controllerContext, string partialViewName, bool useCache)
{
return base.FindPartialView(controllerContext, partialViewName, useCache);
}
#endregion
}
}
Плагинная система на ASP.NET. Или сайт с плагинами, мадемуазелями и преферансом