-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New on net core 3 update #40
Comments
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 Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10
From: Keith Barrows<mailto:[email protected]>
Sent: venerdì 21 febbraio 2020 18:59
To: OdeToCode/AddFeatureFolders<mailto:[email protected]>
Cc: Francesco Venturini<mailto:[email protected]>; Author<mailto:[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 GitHub<#40?email_source=notifications&email_token=ABA62S4W4K3LVJUGBUGQUFTREAI7JA5CNFSM4J2BDLPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEMTRQ4I#issuecomment-589764721>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABA62S77C4JC5SKOTBOVX3LREAI7JANCNFSM4J2BDLPA>.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think this library should allow using all the possibile choices asp.net core has in term of
MVC service registration
The text was updated successfully, but these errors were encountered: