AddFeatureFolders
AddFeatureFolders copied to clipboard
New on net core 3 update
I think this library should allow using all the possibile choices asp.net core has in term of MVC service registration
That’s my solution after extracting your code If work like the past with this new 3.0/1 method AddControllersWithViews
return services.AddControllersWithViews(opt => { opt.Conventions.Add(new FeatureControllerModelConvention(options));
})
.AddRazorOptions(o =>
{
o.ViewLocationFormats.Clear();
o.ViewLocationFormats.Add(options.FeatureNamePlaceholder + @"\{0}.cshtml");
o.ViewLocationFormats.Add(options.FeatureFolderName + @"\Shared\{0}.cshtml");
o.ViewLocationFormats.Add(options.DefaultViewLocation);
o.ViewLocationExpanders.Add(expander);
});
Sent from Mailhttps://go.microsoft.com/fwlink/?LinkId=550986 for Windows 10
From: Keith Barrowsmailto:[email protected] Sent: venerdì 21 febbraio 2020 18:59 To: OdeToCode/AddFeatureFoldersmailto:[email protected] Cc: Francesco Venturinimailto:[email protected]; Authormailto:[email protected] Subject: Re: [OdeToCode/AddFeatureFolders] New on net core 3 update (#40)
Don't know if this will help anyone but I struggled getting this to work in a Core 3.1 web app. Ended up having to tweak the Startup so it no longer quite follows the instructions found in the readme for this repository...
I got everything working with this structure:
[Project]
-
Features (folder)
-- _ViewImports.cshtml
-- _ViewStart.cshtml
-
Home (folder)
-- Error.cshtml
-- ErrorViewModel.cs
-- HomeController.cs
-- Index.cshtml
-- Privavcy.cshtml
-
Shared (folder)
-- _Layout.cshtml
-- _ValidationScriptsPartial.cshtml
-
Startup.cs looks like this:
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace Gallery.Test.Web
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
//services.AddMvc().AddFeatureFolders(); --> NOTE: AddMvc now causes problems.
services.AddControllersWithViews();
services.AddRazorPages().AddFeatureFolders();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
app.UseDeveloperExceptionPage();
else
app.UseExceptionHandler("/Home/Error");
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
//app.UseMvcWithDefaultRoute(); --> NOTE: UseMvc replaced with UseEndpoints.
}
}
}
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/OdeToCode/AddFeatureFolders/issues/40?email_source=notifications&email_token=ABA62S4W4K3LVJUGBUGQUFTREAI7JA5CNFSM4J2BDLPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMTRQ4I#issuecomment-589764721, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ABA62S77C4JC5SKOTBOVX3LREAI7JANCNFSM4J2BDLPA.