Basic MVC application

This commit is contained in:
Unknown
2017-12-21 12:25:05 +00:00
parent 4db6fb0118
commit d97260b7aa
17 changed files with 201 additions and 0 deletions

View 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 });
}
}
}

View 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();
}
}
}

View 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();
}
}
}

View File

@ -0,0 +1,12 @@
{
"profiles": {
"test": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "http://localhost:5000/"
}
}
}

View 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" });
});
}
}
}

View File

@ -0,0 +1 @@
<h1>My about page</h1>

View File

@ -0,0 +1 @@
<h1>Tell me more</h1>

View File

@ -0,0 +1 @@
<h1>Ooops, our site crashed</h1>

View File

@ -0,0 +1 @@
<h1>Hello World</h1>

View File

@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en-GB">
<head>
<meta charset="utf-8">
<title>Title</title>
</head>
<body>
@RenderBody()
</body>
</html>

View File

@ -0,0 +1,2 @@
@using test
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

View File

@ -0,0 +1,3 @@
@{
Layout = "_Layout";
}

View File

@ -0,0 +1,10 @@
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}

View File

@ -0,0 +1,8 @@
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Warning"
}
}
}

View 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>

View 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

View File

@ -0,0 +1 @@
html{ color: red; }