Skip to content

Commit

Permalink
adding atribure rout
Browse files Browse the repository at this point in the history
  • Loading branch information
fMATSINHE committed Jan 4, 2020
1 parent 6d27f78 commit cde61a5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
28 changes: 28 additions & 0 deletions Helloword_core/Controllers/HomeController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace Helloword_core.Controllers
{
[Route("Home")]
public class HomeController : Controller
{
[Route("")]
[Route("Index")]
// GET: /<controller>/
public string Index()
{
return "Hello from HomeController";
}

[Route("About")]
public string About()
{
return "About";
}
}
}
2 changes: 1 addition & 1 deletion Helloword_core/Helloword_core.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
Expand Down
8 changes: 5 additions & 3 deletions Helloword_core/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@ public class Startup
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
//services.AddSingleton<IHello, Hello>();
services.AddSingleton<IHello, Hello>();
services.AddMvc();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILogger<Startup> logger)
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILogger<Startup> logger, IHello hello)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseStaticFiles();
app.UseMvcWithDefaultRoute();
app.Map("/test", testPipeline);
app.Use(next => async context =>
{
Expand All @@ -38,7 +40,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILogger<
app.Run(async (context) =>
{
logger.LogInformation("Response Served.");
await context.Response.WriteAsync("hello word");
await context.Response.WriteAsync(hello.SayHello());
});
}

Expand Down

0 comments on commit cde61a5

Please sign in to comment.