Skip to content

Commit f6379b2

Browse files
committed
Configuring middleware for ASP.NET MVC and adding a basic Home controller
1 parent f0cecd9 commit f6379b2

File tree

4 files changed

+33
-3
lines changed

4 files changed

+33
-3
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace OdeToFoodRider.Controllers
2+
{
3+
public class HomeController
4+
{
5+
public string Index()
6+
{
7+
return "Hello from Rider's Home controller!";
8+
}
9+
}
10+
}

OdeToFoodRider/OdeToFoodRider/Startup.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ public class Startup
1818
public void ConfigureServices(IServiceCollection services)
1919
{
2020
services.AddSingleton<IGreeter, Greeter>();
21+
services.AddMvc();
2122

2223
}
2324

@@ -29,8 +30,9 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, IGreeter
2930
app.UseDeveloperExceptionPage();
3031
}
3132

32-
app.UseFileServer();
33-
33+
app.UseStaticFiles();
34+
app.UseMvcWithDefaultRoute();
35+
3436
app.Run(async (context) =>
3537
{
3638
var greeting = greeter.GetMessageOfTheDay();
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
6+
namespace OdeToFoodVisualStudio.Controllers
7+
{
8+
public class HomeController
9+
{
10+
public string Index()
11+
{
12+
return "Hello from Visual Studio's Home controller";
13+
14+
}
15+
}
16+
}

OdeToFoodVisualStudio/OdeToFoodVisualStudio/Startup.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public void ConfigureServices(IServiceCollection services)
1717
// RDVS: Rider's completion works better with this generic method as it additionally adds the parentheses; additionally, VS overlaps the completion list inside the generic brackets
1818
// with with parameter info
1919
services.AddSingleton<IGreeter, Greeter>();
20+
services.AddMvc();
2021
}
2122

2223
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@@ -27,7 +28,8 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, IGreeter
2728
app.UseDeveloperExceptionPage();
2829
}
2930

30-
app.UseFileServer();
31+
app.UseStaticFiles();
32+
app.UseMvcWithDefaultRoute();
3133

3234
app.Run(async (context) =>
3335
{

0 commit comments

Comments
 (0)