Emanuele Leoni

Emanuele Leoni

  • NA
  • 139
  • 16.1k

ASP.NET Core route works only for Home Controller

Apr 20 2018 5:04 AM
I created a simple MVC .Net Core application with two controllers (Home and Recipes). When I debug it in windows os I can navigate /Home and /Recipes But when I run in linux I can navigate only /Home but not /Recipes. It returns 404.
 
This is my Startup.cs Configure:
  1. using (var serviceScope = app.ApplicationServices.GetService<IServiceScopeFactory>().CreateScope())  
  2. {  
  3. var context = serviceScope.ServiceProvider.GetRequiredService<DbContext>();  
  4. }  
  5. if (env.IsDevelopment())  
  6. {  
  7. app.UseBrowserLink();  
  8. app.UseDeveloperExceptionPage();  
  9. }  
  10. else  
  11. {  
  12. app.UseExceptionHandler("/Home/Error");  
  13. }  
  14. app.UseStaticFiles();  
  15. app.UseMvc(routes =>  
  16. {  
  17. routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}");  
  18. });  
I tried to call:
curl http://localhost:43124/Home/Index and It returns the html of the View curl http://localhost:43124/Recipes/Index and It returns nothing
 
What am I wrong?