Basic MVC application
This commit is contained in:
17
ASP.Net Core/MVCBasics/Controllers/AboutController.cs
Normal file
17
ASP.Net Core/MVCBasics/Controllers/AboutController.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace test.Controllers
|
||||
{
|
||||
public class AboutController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult TellMeMore(string moreInfo = "")
|
||||
{
|
||||
return new JsonResult(new { name = "TellMeMore", content = moreInfo });
|
||||
}
|
||||
}
|
||||
}
|
||||
18
ASP.Net Core/MVCBasics/Controllers/HomeController.cs
Normal file
18
ASP.Net Core/MVCBasics/Controllers/HomeController.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
|
||||
namespace test.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public IActionResult Error()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
22
ASP.Net Core/MVCBasics/Program.cs
Normal file
22
ASP.Net Core/MVCBasics/Program.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using System.IO;
|
||||
|
||||
namespace test
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
BuildWebHost(args).Run();
|
||||
}
|
||||
|
||||
public static IWebHost BuildWebHost(string[] args)
|
||||
{
|
||||
return new WebHostBuilder()
|
||||
.UseKestrel()
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseStartup<Startup>()
|
||||
.Build();
|
||||
}
|
||||
}
|
||||
}
|
||||
12
ASP.Net Core/MVCBasics/Properties/launchSettings.json
Normal file
12
ASP.Net Core/MVCBasics/Properties/launchSettings.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"profiles": {
|
||||
"test": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "http://localhost:5000/"
|
||||
}
|
||||
}
|
||||
}
|
||||
50
ASP.Net Core/MVCBasics/Startup.cs
Normal file
50
ASP.Net Core/MVCBasics/Startup.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace test
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
{
|
||||
Configuration = configuration;
|
||||
}
|
||||
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (env.IsDevelopment())
|
||||
app.UseDeveloperExceptionPage();
|
||||
else
|
||||
app.UseExceptionHandler("/Home/Error");
|
||||
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
routes.MapRoute(
|
||||
name: "default",
|
||||
template: "{controller=Home}/{action=Index}/{moreInfo?}");
|
||||
|
||||
routes.MapRoute(
|
||||
name: "aboutPage",
|
||||
template: "more",
|
||||
defaults: new { controller = "About", action = "TellMeMore" });
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
1
ASP.Net Core/MVCBasics/Views/About/Index.cshtml
Normal file
1
ASP.Net Core/MVCBasics/Views/About/Index.cshtml
Normal file
@ -0,0 +1 @@
|
||||
<h1>My about page</h1>
|
||||
1
ASP.Net Core/MVCBasics/Views/About/TellMeMore.cshtml
Normal file
1
ASP.Net Core/MVCBasics/Views/About/TellMeMore.cshtml
Normal file
@ -0,0 +1 @@
|
||||
<h1>Tell me more</h1>
|
||||
1
ASP.Net Core/MVCBasics/Views/Home/Error.cshtml
Normal file
1
ASP.Net Core/MVCBasics/Views/Home/Error.cshtml
Normal file
@ -0,0 +1 @@
|
||||
<h1>Ooops, our site crashed</h1>
|
||||
1
ASP.Net Core/MVCBasics/Views/Home/Index.cshtml
Normal file
1
ASP.Net Core/MVCBasics/Views/Home/Index.cshtml
Normal file
@ -0,0 +1 @@
|
||||
<h1>Hello World</h1>
|
||||
10
ASP.Net Core/MVCBasics/Views/Shared/_Layout.cshtml
Normal file
10
ASP.Net Core/MVCBasics/Views/Shared/_Layout.cshtml
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-GB">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
@RenderBody()
|
||||
</body>
|
||||
</html>
|
||||
2
ASP.Net Core/MVCBasics/Views/_ViewImports.cshtml
Normal file
2
ASP.Net Core/MVCBasics/Views/_ViewImports.cshtml
Normal file
@ -0,0 +1,2 @@
|
||||
@using test
|
||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
|
||||
3
ASP.Net Core/MVCBasics/Views/_ViewStart.cshtml
Normal file
3
ASP.Net Core/MVCBasics/Views/_ViewStart.cshtml
Normal file
@ -0,0 +1,3 @@
|
||||
@{
|
||||
Layout = "_Layout";
|
||||
}
|
||||
10
ASP.Net Core/MVCBasics/appsettings.Development.json
Normal file
10
ASP.Net Core/MVCBasics/appsettings.Development.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"Logging": {
|
||||
"IncludeScopes": false,
|
||||
"LogLevel": {
|
||||
"Default": "Debug",
|
||||
"System": "Information",
|
||||
"Microsoft": "Information"
|
||||
}
|
||||
}
|
||||
}
|
||||
8
ASP.Net Core/MVCBasics/appsettings.json
Normal file
8
ASP.Net Core/MVCBasics/appsettings.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"IncludeScopes": false,
|
||||
"LogLevel": {
|
||||
"Default": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
19
ASP.Net Core/MVCBasics/test.csproj
Normal file
19
ASP.Net Core/MVCBasics/test.csproj
Normal file
@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="wwwroot\style.xaml" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
25
ASP.Net Core/MVCBasics/test.sln
Normal file
25
ASP.Net Core/MVCBasics/test.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27130.2010
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "test", "test.csproj", "{B6C91DFF-E4A2-4DD3-A357-F8BECCCA183A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{B6C91DFF-E4A2-4DD3-A357-F8BECCCA183A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B6C91DFF-E4A2-4DD3-A357-F8BECCCA183A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B6C91DFF-E4A2-4DD3-A357-F8BECCCA183A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B6C91DFF-E4A2-4DD3-A357-F8BECCCA183A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {75575559-DA47-4D16-803A-735E85EACA3D}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
1
ASP.Net Core/MVCBasics/wwwroot/style.css
Normal file
1
ASP.Net Core/MVCBasics/wwwroot/style.css
Normal file
@ -0,0 +1 @@
|
||||
html{ color: red; }
|
||||
Reference in New Issue
Block a user