Skip to content

Commit 5b3849e

Browse files
committed
Added MVC middleware, controller to handle items and default route
1 parent f3eb4db commit 5b3849e

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using Microsoft.AspNetCore.Mvc;
3+
namespace Practices.Controllers
4+
{
5+
public class ItemsController : Controller
6+
{
7+
8+
public IActionResult Index()
9+
{
10+
return Ok("Meu Index");
11+
}
12+
13+
}
14+
}

ASP.NETPractices/Practices/Startup.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public class Startup
1515
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
1616
public void ConfigureServices(IServiceCollection services)
1717
{
18+
19+
services.AddMvc();
1820
}
1921

2022
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@@ -25,10 +27,16 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
2527
app.UseDeveloperExceptionPage();
2628
}
2729

28-
app.Run(async (context) =>
30+
31+
app.UseMvc(routes => {
32+
routes.MapRoute("default",
33+
template: "{controller=Items}/{action=Index}/{id?}");
34+
});
35+
36+
/*app.Run(async (context) =>
2937
{
3038
await context.Response.WriteAsync("Hello World!");
31-
});
39+
});*/
3240
}
3341
}
3442
}

0 commit comments

Comments
 (0)