{"id":13429768,"url":"https://github.com/OdeToCode/AddFeatureFolders","last_synced_at":"2025-03-16T04:31:04.408Z","repository":{"id":60774124,"uuid":"70425648","full_name":"OdeToCode/AddFeatureFolders","owner":"OdeToCode","description":"Enable feature folders for MVC controllers and views in ASP.NET Core","archived":false,"fork":false,"pushed_at":"2022-10-07T22:33:54.000Z","size":56,"stargazers_count":251,"open_issues_count":6,"forks_count":66,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-02-16T20:18:20.928Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OdeToCode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-09T19:30:38.000Z","updated_at":"2025-02-07T15:16:15.000Z","dependencies_parsed_at":"2023-01-19T14:45:14.781Z","dependency_job_id":null,"html_url":"https://github.com/OdeToCode/AddFeatureFolders","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OdeToCode%2FAddFeatureFolders","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OdeToCode%2FAddFeatureFolders/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OdeToCode%2FAddFeatureFolders/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OdeToCode%2FAddFeatureFolders/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OdeToCode","download_url":"https://codeload.github.com/OdeToCode/AddFeatureFolders/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243826788,"owners_count":20354220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T02:00:45.029Z","updated_at":"2025-03-16T04:31:04.098Z","avatar_url":"https://github.com/OdeToCode.png","language":"C#","readme":"# AddFeatureFolders\n[![Build status](https://ci.appveyor.com/api/projects/status/k4aotmbkugavs2mq?svg=true)](https://ci.appveyor.com/project/OdeToCode/addfeaturefolders)\n### Installation\n```\n    Install-Package OdeToCode.AddFeatureFolders \n```\n\n### Usage \n```c#\n    public class Startup\n    {\n        public void ConfigureServices(IServiceCollection services)\n        {\n            services.AddMvc()\n                    .AddFeatureFolders();\n\n            // \"Features\" is the default feature folder root. To override, pass along \n            // a new FeatureFolderOptions object with a different FeatureFolderName\n        }\n\n        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)\n        {\n            app.UseDeveloperExceptionPage();\n            app.UseMvcWithDefaultRoute();\n        }\n    }    \n```\n\n### Now you can organize controllers and views in a Features folder hierarchy\n\nSee the sample folder for more examples. \n\n\\Features\n  \\Home\n      \\HomeController.cs\n      \\HomeViewModel.cs\n      \\HomeIndexHandler.cs\n      \\HomeIndexQuery.cs\n      \\Index.cshtml\n\n\n### Important!\nAddFeatureFolders **uses the namespace of the controller to figure out where the views are**. \nFor example: \n```\n/Features\n\t/Robots\n\t\t/Robots.cshtml\n```\nThe above example folder structure relies on the namespace of the controller being `\u003cwhatever\u003e.Features.Robots`. \n\nIf you encounter problems with MVC locating the views, check your controller namespace.\n\n#### Disclaimer\n\nYour feature folder name (`FeatureFolderOptions.FeatureFolderName` or `AreaFeatureFolderOptions.AreaFolderName` if using Areas) cannot be in your project namespace.\n\nSee: [Issue #27](https://github.com/OdeToCode/AddFeatureFolders/issues/27)\n\n### Using areas\n\nIf you want to enable areas, there are two pieces of code to add:\n```c#\n    public void ConfigureServices(IServiceCollection services)\n    {\n        services.AddMvc()\n                .AddFeatureFolders()\n                .AddAreaFeatureFolders();\n    \n        // \"Features\" is the default feature folder root. To override, pass along \n        // a new FeatureFolderOptions object with a different FeatureFolderName\n    }\n    \n    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)\n    {\n        app.UseDeveloperExceptionPage();\n        app.UseMvcWithDefaultRoute().UseMvc(routes =\u003e \n            routes.MapRoute(\n                name: \"areaRoute\",\n                template: \"{area:exists}/{controller=Home}/{action=Index}/{id?}\"));\n    }\n```\n\nThe first piece is to add the ```.AddAreaFeaturesFolders()``` after the ```.AddFeatureFolders()```.\nThis adds the view locations for the areas.\nThe second part is another ```.UseMvc()``` method to configure the route to area controllers.\n\nNow areas can be added using the default area layout combined with the feature folder setup.\nExample:\n```\n/Areas\n    /Administration // this is the area name\n        /Overview   // this is the controller name\n            /OverviewController.cs\n            /Index.cshtml\n```  \n\n### If ReSharper (or Rider) is being annoying\nThen add the package ```JetBrains.Annotations``` to the web app project and add the following lines \nabove the Startup class between the using statements and the namespace. \n```c#\n[assembly: AspMvcViewLocationFormat(@\"~\\Features\\{1}\\{0}.cshtml\")]\n[assembly: AspMvcViewLocationFormat(@\"~\\Features\\{0}.cshtml\")]\n[assembly: AspMvcViewLocationFormat(@\"~\\Features\\Shared\\{0}.cshtml\")]\n\n[assembly: AspMvcAreaViewLocationFormat(@\"~\\Areas\\{2}\\{1}\\{0}.cshtml\")]\n[assembly: AspMvcAreaViewLocationFormat(@\"~\\Areas\\{2}\\Features\\{1}\\{0}.cshtml\")]\n[assembly: AspMvcAreaViewLocationFormat(@\"~\\Areas\\{2}\\{0}.cshtml\")]\n[assembly: AspMvcAreaViewLocationFormat(@\"~\\Areas\\{2}\\Shared\\{0}.cshtml\")]\n```\nReplace 'Features' and 'Areas' part if you set a custom folder name.\n","funding_links":[],"categories":["Frameworks, Libraries and Tools","框架, 库和工具","Application Templates"],"sub_categories":["Application Templates","应用程序模板"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FOdeToCode%2FAddFeatureFolders","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FOdeToCode%2FAddFeatureFolders","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FOdeToCode%2FAddFeatureFolders/lists"}