From b72d92340706ac508e6ea367f592f5e7d3462caa Mon Sep 17 00:00:00 2001 From: Nick Rirush Date: Sat, 9 Feb 2019 10:38:05 +0800 Subject: [PATCH] Add HomeController and reorganize code --- Controllers/HomeController.cs | 13 ++++++++++ Pages/Index.cshtml | 2 -- Pages/_Layout.cshtml | 15 ------------ Pages/_ViewImports.cshtml | 0 Pages/_ViewStart.cshtml | 3 --- Source/Startup.cs | 5 +++- Views/Home/Index.cshtml | 5 ++++ Views/Shared/_Layout.cshtml | 56 +++++++++++++++++++++++++++++++++++++++++++ Views/_ViewImports.cshtml | 0 Views/_ViewStart.cshtml | 3 +++ 10 files changed, 81 insertions(+), 21 deletions(-) create mode 100644 Controllers/HomeController.cs delete mode 100644 Pages/Index.cshtml delete mode 100644 Pages/_Layout.cshtml delete mode 100644 Pages/_ViewImports.cshtml delete mode 100644 Pages/_ViewStart.cshtml create mode 100644 Views/Home/Index.cshtml create mode 100644 Views/Shared/_Layout.cshtml create mode 100644 Views/_ViewImports.cshtml create mode 100644 Views/_ViewStart.cshtml diff --git a/Controllers/HomeController.cs b/Controllers/HomeController.cs new file mode 100644 index 0000000..30395ec --- /dev/null +++ b/Controllers/HomeController.cs @@ -0,0 +1,13 @@ +using System; +using Microsoft.AspNetCore.Mvc; + +namespace QuickCHAT.Controllers { + [Controller] + public class HomeController : Controller + { + public ActionResult Index() + { + return View(); + } + } +} \ No newline at end of file diff --git a/Pages/Index.cshtml b/Pages/Index.cshtml deleted file mode 100644 index 49de0f2..0000000 --- a/Pages/Index.cshtml +++ /dev/null @@ -1,2 +0,0 @@ -@page -

Hello, World!

\ No newline at end of file diff --git a/Pages/_Layout.cshtml b/Pages/_Layout.cshtml deleted file mode 100644 index ae7c714..0000000 --- a/Pages/_Layout.cshtml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - @ViewData["Title"] - QuickCHAT - - - - - - -
- @RenderBody() -
- \ No newline at end of file diff --git a/Pages/_ViewImports.cshtml b/Pages/_ViewImports.cshtml deleted file mode 100644 index e69de29..0000000 diff --git a/Pages/_ViewStart.cshtml b/Pages/_ViewStart.cshtml deleted file mode 100644 index d641c67..0000000 --- a/Pages/_ViewStart.cshtml +++ /dev/null @@ -1,3 +0,0 @@ -@{ - Layout = "_Layout"; -} \ No newline at end of file diff --git a/Source/Startup.cs b/Source/Startup.cs index e29980f..c287d3e 100644 --- a/Source/Startup.cs +++ b/Source/Startup.cs @@ -50,7 +50,10 @@ namespace QuickCHAT app.UseHttpsRedirection(); } app.UseAuthentication(); - app.UseMvc(); + app.UseMvc(routes => + { + routes.MapRoute("default", "{controller=Home}/{action=Index}"); + }); } } } diff --git a/Views/Home/Index.cshtml b/Views/Home/Index.cshtml new file mode 100644 index 0000000..a00358f --- /dev/null +++ b/Views/Home/Index.cshtml @@ -0,0 +1,5 @@ +@page +@{ + ViewBag.Title = "Index"; +} +

QuickCHAT

\ No newline at end of file diff --git a/Views/Shared/_Layout.cshtml b/Views/Shared/_Layout.cshtml new file mode 100644 index 0000000..38d5300 --- /dev/null +++ b/Views/Shared/_Layout.cshtml @@ -0,0 +1,56 @@ + + + + + @ViewData["Title"] - QuickCHAT + + + + + + + @if(ViewData["HideNavbar"] == null) + { + + } +
+ @RenderBody() +
+ \ No newline at end of file diff --git a/Views/_ViewImports.cshtml b/Views/_ViewImports.cshtml new file mode 100644 index 0000000..e69de29 diff --git a/Views/_ViewStart.cshtml b/Views/_ViewStart.cshtml new file mode 100644 index 0000000..d641c67 --- /dev/null +++ b/Views/_ViewStart.cshtml @@ -0,0 +1,3 @@ +@{ + Layout = "_Layout"; +} \ No newline at end of file