Skip to content

Commit

Permalink
Configuring middleware for ASP.NET MVC and adding a basic Home contro…
Browse files Browse the repository at this point in the history
…ller
  • Loading branch information
gorohoroh committed Jul 3, 2018
1 parent f0cecd9 commit f6379b2
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
10 changes: 10 additions & 0 deletions OdeToFoodRider/OdeToFoodRider/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace OdeToFoodRider.Controllers
{
public class HomeController
{
public string Index()
{
return "Hello from Rider's Home controller!";
}
}
}
6 changes: 4 additions & 2 deletions OdeToFoodRider/OdeToFoodRider/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class Startup
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IGreeter, Greeter>();
services.AddMvc();

}

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

app.UseFileServer();

app.UseStaticFiles();
app.UseMvcWithDefaultRoute();

app.Run(async (context) =>
{
var greeting = greeter.GetMessageOfTheDay();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace OdeToFoodVisualStudio.Controllers
{
public class HomeController
{
public string Index()
{
return "Hello from Visual Studio's Home controller";

}
}
}
4 changes: 3 additions & 1 deletion OdeToFoodVisualStudio/OdeToFoodVisualStudio/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public void ConfigureServices(IServiceCollection services)
// 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
// with with parameter info
services.AddSingleton<IGreeter, Greeter>();
services.AddMvc();
}

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

app.UseFileServer();
app.UseStaticFiles();
app.UseMvcWithDefaultRoute();

app.Run(async (context) =>
{
Expand Down

0 comments on commit f6379b2

Please sign in to comment.