* Remove MvcSample and replace with MvcSandbox
This commit is contained in:
parent
4a61dfec6d
commit
b6f8c523a8
|
|
@ -19,8 +19,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Razor.
|
|||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Core.Test", "test\Microsoft.AspNet.Mvc.Core.Test\Microsoft.AspNet.Mvc.Core.Test.xproj", "{A8AA326E-8EE8-4F11-B750-23028E0949D7}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MvcSample.Web", "samples\MvcSample.Web\MvcSample.Web.xproj", "{FBB2B86E-972B-4185-9FF2-62CAB5F8388F}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Razor.Host", "src\Microsoft.AspNet.Mvc.Razor.Host\Microsoft.AspNet.Mvc.Razor.Host.xproj", "{520B3AA4-363A-497C-8C15-80423C5AFC85}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Razor.Host.Test", "test\Microsoft.AspNet.Mvc.Razor.Host.Test\Microsoft.AspNet.Mvc.Razor.Host.Test.xproj", "{7C4F5973-0491-4028-B1DC-A9BA73FF9F77}"
|
||||
|
|
@ -86,6 +84,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Locali
|
|||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.TestDiagnosticListener.Sources", "test\Microsoft.AspNet.Mvc.TestDiagnosticListener.Sources\Microsoft.AspNet.Mvc.TestDiagnosticListener.Sources.xproj", "{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MvcSandbox", "samples\MvcSandbox\MvcSandbox.xproj", "{14ED4476-9F24-4776-8417-EA6927F6C9C9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -146,16 +146,6 @@ Global
|
|||
{A8AA326E-8EE8-4F11-B750-23028E0949D7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{A8AA326E-8EE8-4F11-B750-23028E0949D7}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{A8AA326E-8EE8-4F11-B750-23028E0949D7}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{FBB2B86E-972B-4185-9FF2-62CAB5F8388F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FBB2B86E-972B-4185-9FF2-62CAB5F8388F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FBB2B86E-972B-4185-9FF2-62CAB5F8388F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{FBB2B86E-972B-4185-9FF2-62CAB5F8388F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{FBB2B86E-972B-4185-9FF2-62CAB5F8388F}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{FBB2B86E-972B-4185-9FF2-62CAB5F8388F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FBB2B86E-972B-4185-9FF2-62CAB5F8388F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FBB2B86E-972B-4185-9FF2-62CAB5F8388F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{FBB2B86E-972B-4185-9FF2-62CAB5F8388F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{FBB2B86E-972B-4185-9FF2-62CAB5F8388F}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{520B3AA4-363A-497C-8C15-80423C5AFC85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{520B3AA4-363A-497C-8C15-80423C5AFC85}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{520B3AA4-363A-497C-8C15-80423C5AFC85}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
|
|
@ -504,6 +494,18 @@ Global
|
|||
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|x86.Build.0 = Release|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -514,7 +516,6 @@ Global
|
|||
{C48DA9D7-ACB5-4408-AA79-27ECB60A67EF} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E}
|
||||
{3F6E355E-4869-41D9-943B-D54771221A7F} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
|
||||
{A8AA326E-8EE8-4F11-B750-23028E0949D7} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
|
||||
{FBB2B86E-972B-4185-9FF2-62CAB5F8388F} = {DAAE4C74-D06F-4874-A166-33305D2643CE}
|
||||
{520B3AA4-363A-497C-8C15-80423C5AFC85} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E}
|
||||
{7C4F5973-0491-4028-B1DC-A9BA73FF9F77} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
|
||||
{5F945B82-FE5F-425C-956C-8BC2F2020254} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
|
||||
|
|
@ -545,5 +546,6 @@ Global
|
|||
{50893B10-5735-4F35-9995-F81DA3F0189E} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E}
|
||||
{8FC726B5-E766-44E0-8B38-1313B6D8D9A7} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
|
||||
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9} = {DAAE4C74-D06F-4874-A166-33305D2643CE}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
|||
28
Mvc.sln
28
Mvc.sln
|
|
@ -19,8 +19,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Razor.
|
|||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Core.Test", "test\Microsoft.AspNet.Mvc.Core.Test\Microsoft.AspNet.Mvc.Core.Test.xproj", "{A8AA326E-8EE8-4F11-B750-23028E0949D7}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MvcSample.Web", "samples\MvcSample.Web\MvcSample.Web.xproj", "{FBB2B86E-972B-4185-9FF2-62CAB5F8388F}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Razor.Host", "src\Microsoft.AspNet.Mvc.Razor.Host\Microsoft.AspNet.Mvc.Razor.Host.xproj", "{520B3AA4-363A-497C-8C15-80423C5AFC85}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Razor.Host.Test", "test\Microsoft.AspNet.Mvc.Razor.Host.Test\Microsoft.AspNet.Mvc.Razor.Host.Test.xproj", "{7C4F5973-0491-4028-B1DC-A9BA73FF9F77}"
|
||||
|
|
@ -180,6 +178,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.Locali
|
|||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.TestDiagnosticListener.Sources", "test\Microsoft.AspNet.Mvc.TestDiagnosticListener.Sources\Microsoft.AspNet.Mvc.TestDiagnosticListener.Sources.xproj", "{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "MvcSandbox", "samples\MvcSandbox\MvcSandbox.xproj", "{14ED4476-9F24-4776-8417-EA6927F6C9C9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -240,16 +240,6 @@ Global
|
|||
{A8AA326E-8EE8-4F11-B750-23028E0949D7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{A8AA326E-8EE8-4F11-B750-23028E0949D7}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{A8AA326E-8EE8-4F11-B750-23028E0949D7}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{FBB2B86E-972B-4185-9FF2-62CAB5F8388F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FBB2B86E-972B-4185-9FF2-62CAB5F8388F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FBB2B86E-972B-4185-9FF2-62CAB5F8388F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{FBB2B86E-972B-4185-9FF2-62CAB5F8388F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{FBB2B86E-972B-4185-9FF2-62CAB5F8388F}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{FBB2B86E-972B-4185-9FF2-62CAB5F8388F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FBB2B86E-972B-4185-9FF2-62CAB5F8388F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FBB2B86E-972B-4185-9FF2-62CAB5F8388F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{FBB2B86E-972B-4185-9FF2-62CAB5F8388F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{FBB2B86E-972B-4185-9FF2-62CAB5F8388F}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{520B3AA4-363A-497C-8C15-80423C5AFC85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{520B3AA4-363A-497C-8C15-80423C5AFC85}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{520B3AA4-363A-497C-8C15-80423C5AFC85}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
|
|
@ -1101,6 +1091,18 @@ Global
|
|||
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4}.Release|x86.Build.0 = Release|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -1111,7 +1113,6 @@ Global
|
|||
{C48DA9D7-ACB5-4408-AA79-27ECB60A67EF} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E}
|
||||
{3F6E355E-4869-41D9-943B-D54771221A7F} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
|
||||
{A8AA326E-8EE8-4F11-B750-23028E0949D7} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
|
||||
{FBB2B86E-972B-4185-9FF2-62CAB5F8388F} = {DAAE4C74-D06F-4874-A166-33305D2643CE}
|
||||
{520B3AA4-363A-497C-8C15-80423C5AFC85} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E}
|
||||
{7C4F5973-0491-4028-B1DC-A9BA73FF9F77} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
|
||||
{16703B76-C9F7-4C75-AE6C-53D92E308E3C} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
|
||||
|
|
@ -1189,5 +1190,6 @@ Global
|
|||
{50893B10-5735-4F35-9995-F81DA3F0189E} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E}
|
||||
{8FC726B5-E766-44E0-8B38-1313B6D8D9A7} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
|
||||
{9879B5D5-2325-4A81-B4DF-F279FE8FEEB4} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1}
|
||||
{14ED4476-9F24-4776-8417-EA6927F6C9C9} = {DAAE4C74-D06F-4874-A166-33305D2643CE}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.ApiExplorer;
|
||||
|
||||
namespace MvcSample.Web
|
||||
{
|
||||
[Route("ApiExplorer")]
|
||||
public class ApiExplorerController : Controller
|
||||
{
|
||||
public ApiExplorerController(IApiDescriptionGroupCollectionProvider provider)
|
||||
{
|
||||
Provider = provider;
|
||||
}
|
||||
|
||||
public IApiDescriptionGroupCollectionProvider Provider { get; }
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult All()
|
||||
{
|
||||
var descriptions = Provider.ApiDescriptionGroups.Items;
|
||||
return View(descriptions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Mvc;
|
||||
|
||||
namespace MvcSample.Web
|
||||
{
|
||||
[Area("Travel")]
|
||||
public class Flight : Controller
|
||||
{
|
||||
public IActionResult Fly()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
@using MvcSample.Web.Models
|
||||
@model User
|
||||
@{
|
||||
Layout = "/Views/Shared/_Layout.cshtml";
|
||||
ViewBag.Title = "This is the FLY action";
|
||||
}
|
||||
|
||||
<div class="jumbotron">
|
||||
<h1>ASP.NET</h1>
|
||||
<p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p>
|
||||
<p><a href="http://asp.net" class="btn btn-primary btn-large">Learn more »</a></p>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<h2>Back to the main Area.</h2>
|
||||
<p>Takes you out of the area implicitly.</p>
|
||||
<p><a class="btn btn-default" href="@Url.Action("Create", "Home")">Go to Home/Create</a></p>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h2>Go to another action in the Area.</h2>
|
||||
<p>Keeps you in the area implicitly.</p>
|
||||
<p><a class="btn btn-default" href="@Url.Action("Index", "Home")">Go to Travel/Home/Index</a></p>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h2>Back to the main Area (explicit).</h2>
|
||||
<p>Leaves the area explicitly.</p>
|
||||
<p><a class="btn btn-default" href="@Url.Action("Index", "Home", new { area = string.Empty })">Go to Home/Index</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Mvc.ApplicationModels;
|
||||
|
||||
namespace MvcSample.Web
|
||||
{
|
||||
// Adds an auto-generated route-name to each action in the controller
|
||||
public class AutoGenerateRouteNamesAttribute : Attribute, IControllerModelConvention
|
||||
{
|
||||
public void Apply(ControllerModel model)
|
||||
{
|
||||
foreach (var action in model.Actions)
|
||||
{
|
||||
if (action.AttributeRouteModel == null)
|
||||
{
|
||||
action.AttributeRouteModel = new AttributeRouteModel();
|
||||
}
|
||||
|
||||
if (action.AttributeRouteModel.Name == null)
|
||||
{
|
||||
action.AttributeRouteModel.Name = string.Format(
|
||||
"{0}_{1}",
|
||||
model.ControllerName,
|
||||
action.ActionName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
|
||||
namespace MvcSample.Web.Components
|
||||
{
|
||||
[ViewComponent(Name = "Tags")]
|
||||
public class TagCloud : ViewComponent
|
||||
{
|
||||
private readonly string[] Tags =
|
||||
("Lorem ipsum dolor sit amet consectetur adipisicing elit sed do eiusmod tempor incididunt ut labore et dolore magna aliqua" +
|
||||
"Ut enim ad minim veniam quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat Duis aute irure " +
|
||||
"dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur Excepteur sint occaecat cupidatat" +
|
||||
"non proident, sunt in culpa qui officia deserunt mollit anim id est laborum")
|
||||
.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
|
||||
.OrderBy(s => Guid.NewGuid().ToString())
|
||||
.ToArray();
|
||||
|
||||
public async Task<IViewComponentResult> InvokeAsync(int count, string returnAs)
|
||||
{
|
||||
var tags = await GetTagsAsync(count);
|
||||
|
||||
if (returnAs.Equals("Content", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return Content(string.Join(", ", tags));
|
||||
}
|
||||
if (returnAs.Equals("Json", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return Json(tags);
|
||||
}
|
||||
|
||||
return View(tags);
|
||||
}
|
||||
|
||||
public IViewComponentResult Invoke(int count)
|
||||
{
|
||||
var tags = GetTags(count);
|
||||
return View(tags);
|
||||
}
|
||||
|
||||
private Task<string[]> GetTagsAsync(int count)
|
||||
{
|
||||
return Task.FromResult(GetTags(count));
|
||||
}
|
||||
|
||||
private string[] GetTags(int count)
|
||||
{
|
||||
@ViewBag.Title = count.ToString() + " Tags:";
|
||||
return Tags.Take(count).ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
|
||||
namespace MvcSample.Web.ApiExplorerSamples
|
||||
{
|
||||
[ApiExplorerSettings(GroupName = "Admin API")]
|
||||
[Route("api/Admin/Products")]
|
||||
public class ProductsAdminController : Controller
|
||||
{
|
||||
[HttpPut]
|
||||
[Produces("application/json", Type = typeof(Product))]
|
||||
public IActionResult AddProduct([FromBody] Product product)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
[HttpPost("{id?}")]
|
||||
[Produces("application/json", Type = typeof(Product))]
|
||||
public IActionResult UpdateProduct(UpdateProductDTO dto)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
[HttpPost("{id}/Stock")]
|
||||
public void SetQuantityInStock(int id, int quantity)
|
||||
{
|
||||
}
|
||||
|
||||
[HttpPost("{id}/Price")]
|
||||
public void SetPrice(int id, decimal price)
|
||||
{
|
||||
}
|
||||
|
||||
[Produces("application/json", "application/xml")]
|
||||
[HttpGet("{id}/Orders")]
|
||||
public IEnumerable<ProductOrderConfirmation> GetOrders(DateTime? fromData = null, DateTime? toDate = null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
|
||||
namespace MvcSample.Web.ApiExplorerSamples
|
||||
{
|
||||
[ApiExplorerSettings(GroupName = "Public API")]
|
||||
[Produces("application/json")]
|
||||
[Route("api/Products")]
|
||||
public class ProductsController : Controller
|
||||
{
|
||||
[HttpGet("{id:int}")]
|
||||
public Product GetById(int id)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
[HttpGet("Search/{name}")]
|
||||
public IEnumerable<Product> SearchByName(string name)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
[Produces("application/json", Type = typeof(ProductOrderConfirmation))]
|
||||
[HttpPut("{id:int}/Buy")]
|
||||
public IActionResult Buy(int projectId, int quantity = 1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
[Produces("application/json", Type = typeof(ProductOrderConfirmation))]
|
||||
[HttpPut("{order.acountId:int}/PlaceOrder")]
|
||||
public IActionResult PlaceOrder(Order order)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
|
||||
namespace MvcSample.Web.Controllers
|
||||
{
|
||||
public class FormUrlEncodedController : Controller
|
||||
{
|
||||
[Route("[controller]")]
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[Route("[controller]/[action]")]
|
||||
public bool IsValidPerson(Person person)
|
||||
{
|
||||
return ModelState.IsValid && person.PastJobs.Any();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Mvc;
|
||||
|
||||
namespace MvcSample.Web.Controllers
|
||||
{
|
||||
[Route("[controller]/[action]/{id}.{format?}")]
|
||||
public class FormatFilterController : Controller
|
||||
{
|
||||
public Product GetProduct(int id)
|
||||
{
|
||||
return new Product() { SampleInt = id };
|
||||
}
|
||||
|
||||
[Produces("application/json", "text/json")]
|
||||
public Product ProducesMethod(int id)
|
||||
{
|
||||
return new Product() { SampleInt = id }; ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNet.JsonPatch;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
|
||||
namespace MvcSample.Web.Controllers
|
||||
{
|
||||
[Route("api/[controller]")]
|
||||
public class JsonPatchController : Controller
|
||||
{
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPatch]
|
||||
public IActionResult Patch([FromBody] JsonPatchDocument<Customer> patchDoc)
|
||||
{
|
||||
var customer = new Customer
|
||||
{
|
||||
Name = "John",
|
||||
Orders = new List<Order>()
|
||||
{
|
||||
new Order
|
||||
{
|
||||
OrderName = "Order1"
|
||||
},
|
||||
new Order
|
||||
{
|
||||
OrderName = "Order2"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
patchDoc.ApplyTo(customer, ModelState);
|
||||
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return HttpBadRequest(ModelState);
|
||||
}
|
||||
|
||||
return new ObjectResult(customer);
|
||||
}
|
||||
|
||||
public class Customer
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public List<Order> Orders { get; set; }
|
||||
}
|
||||
|
||||
public class Order
|
||||
{
|
||||
public string OrderName { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Filters;
|
||||
|
||||
namespace MvcSample.Web.Filters
|
||||
{
|
||||
public class AgeEnhancerFilterAttribute : ActionFilterAttribute
|
||||
{
|
||||
public override void OnActionExecuting(ActionExecutingContext context)
|
||||
{
|
||||
object age = null;
|
||||
|
||||
var controller = context.Controller as FiltersController;
|
||||
|
||||
if (controller != null)
|
||||
{
|
||||
controller.CustomUser.Log += "Age Enhanced!" + Environment.NewLine;
|
||||
}
|
||||
|
||||
if (context.ActionArguments.TryGetValue("age", out age))
|
||||
{
|
||||
if (age is int)
|
||||
{
|
||||
var intAge = (int)age;
|
||||
|
||||
if (intAge < 21)
|
||||
{
|
||||
intAge += 5;
|
||||
}
|
||||
else if (intAge > 30)
|
||||
{
|
||||
intAge = 29;
|
||||
}
|
||||
|
||||
context.ActionArguments["age"] = intAge;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Mvc.Filters;
|
||||
|
||||
namespace MvcSample.Web.Filters
|
||||
{
|
||||
public class BlockAnonymous : AuthorizationFilterAttribute
|
||||
{
|
||||
public override void OnAuthorization(AuthorizationContext context)
|
||||
{
|
||||
if (!HasAllowAnonymous(context))
|
||||
{
|
||||
var user = context.HttpContext.User;
|
||||
var userIsAnonymous =
|
||||
user == null ||
|
||||
user.Identity == null ||
|
||||
!user.Identity.IsAuthenticated;
|
||||
|
||||
if (userIsAnonymous)
|
||||
{
|
||||
base.Fail(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Filters;
|
||||
|
||||
namespace MvcSample.Web.Filters
|
||||
{
|
||||
public class DelayAttribute : ActionFilterAttribute
|
||||
{
|
||||
public DelayAttribute(int milliseconds)
|
||||
{
|
||||
Delay = TimeSpan.FromMilliseconds(milliseconds);
|
||||
}
|
||||
|
||||
public TimeSpan Delay { get; private set; }
|
||||
|
||||
public override async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
if (context.HttpContext.Request.Method == "GET")
|
||||
{
|
||||
// slow down incoming GET requests
|
||||
await Task.Delay(Delay);
|
||||
}
|
||||
|
||||
var executedContext = await next();
|
||||
|
||||
if (executedContext.Result is ViewResult)
|
||||
{
|
||||
// slow down outgoing view results
|
||||
await Task.Delay(Delay);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Filters;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
|
||||
namespace MvcSample.Web
|
||||
{
|
||||
public class ErrorMessagesAttribute : ActionFilterAttribute
|
||||
{
|
||||
public override void OnActionExecuted(ActionExecutedContext context)
|
||||
{
|
||||
if (context.Exception != null && !context.ExceptionHandled)
|
||||
{
|
||||
context.ExceptionHandled = true;
|
||||
|
||||
context.Result = new ContentResult
|
||||
{
|
||||
ContentType = new MediaTypeHeaderValue("text/plain"),
|
||||
Content = "Boom " + context.Exception.Message
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Security.Claims;
|
||||
using Microsoft.AspNet.Mvc.Filters;
|
||||
|
||||
namespace MvcSample.Web
|
||||
{
|
||||
public class FakeUserAttribute : AuthorizationFilterAttribute
|
||||
{
|
||||
public override void OnAuthorization(AuthorizationContext context)
|
||||
{
|
||||
context.HttpContext.User = new ClaimsPrincipal(
|
||||
new ClaimsIdentity(
|
||||
new Claim[] {
|
||||
new Claim("Permission", "CanViewPage"),
|
||||
new Claim(ClaimTypes.Role, "Administrator"),
|
||||
new Claim(ClaimTypes.NameIdentifier, "John")},
|
||||
"Basic"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Filters;
|
||||
using MvcSample.Web.Models;
|
||||
|
||||
namespace MvcSample.Web.Filters
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
|
||||
public class InspectResultPageAttribute : Attribute, IFilterFactory
|
||||
{
|
||||
public IFilterMetadata CreateInstance(IServiceProvider serviceProvider)
|
||||
{
|
||||
return new InspectResultPageFilter();
|
||||
}
|
||||
|
||||
private class InspectResultPageFilter : IResultFilter
|
||||
{
|
||||
public void OnResultExecuting(ResultExecutingContext context)
|
||||
{
|
||||
var viewResult = context.Result as ViewResult;
|
||||
|
||||
if (viewResult != null)
|
||||
{
|
||||
var user = viewResult.ViewData.Model as User;
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
user.Name += "**" + user.Name + "**";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnResultExecuted(ResultExecutedContext context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc.Filters;
|
||||
|
||||
namespace MvcSample.Web
|
||||
{
|
||||
public class PassThroughAttribute : AuthorizationFilterAttribute
|
||||
{
|
||||
#pragma warning disable 1998
|
||||
public override async Task OnAuthorizationAsync(AuthorizationContext context)
|
||||
{
|
||||
}
|
||||
#pragma warning restore 1998
|
||||
}
|
||||
}
|
||||
|
|
@ -1,35 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Mvc.Filters;
|
||||
|
||||
namespace MvcSample.Web.Filters
|
||||
{
|
||||
public class UserNameProvider : IActionFilter
|
||||
{
|
||||
private readonly UserNameService _nameService;
|
||||
|
||||
public UserNameProvider(UserNameService nameService)
|
||||
{
|
||||
_nameService = nameService;
|
||||
}
|
||||
|
||||
public void OnActionExecuting(ActionExecutingContext context)
|
||||
{
|
||||
object originalUserName = null;
|
||||
|
||||
context.ActionArguments.TryGetValue("userName", out originalUserName);
|
||||
|
||||
var userName = originalUserName as string;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(userName))
|
||||
{
|
||||
context.ActionArguments["userName"] = _nameService.GetName();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnActionExecuted(ActionExecutedContext context)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace MvcSample.Web.Filters
|
||||
{
|
||||
public class UserNameService
|
||||
{
|
||||
private static readonly string[] _userNames = new[] { "Jon", "David", "Goliath" };
|
||||
private static int _index;
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return _userNames[_index++ % 3];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Authorization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Filters;
|
||||
using MvcSample.Web.Filters;
|
||||
using MvcSample.Web.Models;
|
||||
|
||||
namespace MvcSample.Web
|
||||
{
|
||||
[ServiceFilter(typeof(PassThroughAttribute), Order = 1)]
|
||||
[ServiceFilter(typeof(PassThroughAttribute))]
|
||||
[PassThrough(Order = 0)]
|
||||
[PassThrough(Order = 2)]
|
||||
[InspectResultPage]
|
||||
[BlockAnonymous]
|
||||
[TypeFilter(typeof(UserNameProvider), Order = -1)]
|
||||
public class FiltersController : Controller
|
||||
{
|
||||
public User CustomUser { get; set; }
|
||||
|
||||
public FiltersController()
|
||||
{
|
||||
CustomUser = new User() { Name = "User Name", Address = "Home Address" };
|
||||
}
|
||||
|
||||
[ServiceFilter(typeof(PassThroughAttribute))]
|
||||
[AllowAnonymous]
|
||||
[AgeEnhancerFilter]
|
||||
[Delay(500)]
|
||||
public ActionResult Index(int age = 20, string userName = "SampleUser")
|
||||
{
|
||||
if (!string.IsNullOrEmpty(userName))
|
||||
{
|
||||
CustomUser.Name = userName;
|
||||
}
|
||||
|
||||
CustomUser.Age = age;
|
||||
|
||||
return View("MyView", CustomUser);
|
||||
}
|
||||
|
||||
public ActionResult Blocked(int age = 20, string userName = "SampleUser")
|
||||
{
|
||||
return Index(age, userName);
|
||||
}
|
||||
|
||||
public ActionResult ChallengeUser(int age = 20, string userName = "SampleUser")
|
||||
{
|
||||
return new ChallengeResult();
|
||||
}
|
||||
|
||||
public ActionResult NotGrantedClaim(int age = 20, string userName = "SampleUser")
|
||||
{
|
||||
return Index(age, userName);
|
||||
}
|
||||
|
||||
[FakeUser]
|
||||
public ActionResult AllGranted(int age = 20, string userName = "SampleUser")
|
||||
{
|
||||
return Index(age, userName);
|
||||
}
|
||||
|
||||
[ErrorMessages, AllowAnonymous]
|
||||
public ActionResult Crash(string message = "Sample crash message")
|
||||
{
|
||||
throw new Exception(message);
|
||||
}
|
||||
|
||||
public override void OnActionExecuting(ActionExecutingContext context)
|
||||
{
|
||||
ViewBag.DidTheFilterRun = "Totally!";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using MvcSample.Web.Models;
|
||||
|
||||
namespace MvcSample.Web.RandomNameSpace
|
||||
{
|
||||
public class Home2Controller
|
||||
{
|
||||
private User _user = new User() { Name = "User Name", Address = "Home Address" };
|
||||
|
||||
[ActionContext]
|
||||
public ActionContext ActionContext { get; set; }
|
||||
|
||||
public HttpResponse Response => ActionContext.HttpContext.Response;
|
||||
|
||||
public string Index()
|
||||
{
|
||||
return "Hello World: my namespace is " + this.GetType().Namespace;
|
||||
}
|
||||
|
||||
public ActionResult Something()
|
||||
{
|
||||
return new ContentResult
|
||||
{
|
||||
Content = "Hello World From Content"
|
||||
};
|
||||
}
|
||||
|
||||
public ActionResult Hello()
|
||||
{
|
||||
return new ContentResult
|
||||
{
|
||||
Content = "Hello World",
|
||||
};
|
||||
}
|
||||
|
||||
public async Task Raw()
|
||||
{
|
||||
await Response.WriteAsync("Hello World raw");
|
||||
}
|
||||
|
||||
public ActionResult UserJson()
|
||||
{
|
||||
var jsonResult = new JsonResult(_user);
|
||||
|
||||
return jsonResult;
|
||||
}
|
||||
|
||||
public User User()
|
||||
{
|
||||
return _user;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,255 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.AspNet.Http;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Rendering;
|
||||
using MvcSample.Web.Models;
|
||||
|
||||
namespace MvcSample.Web
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private static readonly IEnumerable<SelectListItem> _addresses = CreateAddresses();
|
||||
private static readonly IEnumerable<SelectListItem> _ages = CreateAges();
|
||||
|
||||
public ActionResult Index()
|
||||
{
|
||||
return View("MyView", CreateUser());
|
||||
}
|
||||
|
||||
public IActionResult NullUser()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public ActionResult ValidationSummary()
|
||||
{
|
||||
ModelState.AddModelError("something", "Something happened, show up in validation summary.");
|
||||
|
||||
return View("ValidationSummary");
|
||||
}
|
||||
|
||||
public ActionResult InjectSample()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[SkipStatusCodePages]
|
||||
public ActionResult NotFound()
|
||||
{
|
||||
return HttpNotFound();
|
||||
}
|
||||
|
||||
public ActionResult SendFileFromDisk()
|
||||
{
|
||||
return File("sample.txt", "text/plain");
|
||||
}
|
||||
|
||||
public ActionResult SendFileFromDiskWithName()
|
||||
{
|
||||
return File("sample.txt", "text/plain", "sample-file.txt");
|
||||
}
|
||||
|
||||
public bool IsDefaultNameSpace()
|
||||
{
|
||||
var namespaceToken = RouteData.DataTokens["NameSpace"] as string;
|
||||
return namespaceToken == "default";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Action that shows metadata when model is <c>null</c>.
|
||||
/// </summary>
|
||||
public ActionResult Create()
|
||||
{
|
||||
ViewBag.Address = _addresses;
|
||||
ViewBag.Ages = _ages;
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Action that shows metadata when model is non-<c>null</c>.
|
||||
/// </summary>
|
||||
public ActionResult Edit(User user)
|
||||
{
|
||||
ViewBag.Address = _addresses;
|
||||
ViewBag.Ages = _ages;
|
||||
ViewBag.Gift = "the banana";
|
||||
|
||||
return View("Create");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Action that exercises query\form based model binding.
|
||||
/// </summary>
|
||||
public ActionResult SaveUser(User user)
|
||||
{
|
||||
return View("MyView", user);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Action that shows multiple file upload.
|
||||
/// </summary>
|
||||
public async Task<ActionResult> PostFile(
|
||||
[FromServices] IHostingEnvironment hostingEnvironment,
|
||||
IList<IFormFile> files)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
return View("MyView");
|
||||
}
|
||||
|
||||
foreach (var f in files)
|
||||
{
|
||||
await f.SaveAsAsync(Path.Combine(hostingEnvironment.WebRootPath, "test-file" + files.IndexOf(f)));
|
||||
}
|
||||
return View();
|
||||
}
|
||||
|
||||
public ActionResult AddTempData()
|
||||
{
|
||||
TempData["controllerData"] = "Temporary data from controller through ViewBag.";
|
||||
TempData["tempData"] = "Temporary data directly from TempData.";
|
||||
return RedirectToAction("UseTempData");
|
||||
}
|
||||
|
||||
public ActionResult UseTempData()
|
||||
{
|
||||
var data = TempData["controllerData"];
|
||||
ViewBag.TempData = data;
|
||||
|
||||
return View("MyView", CreateUser());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Action that exercises input formatter
|
||||
/// </summary>
|
||||
public ActionResult Post([FromBody]User user)
|
||||
{
|
||||
return View("MyView", user);
|
||||
}
|
||||
|
||||
public ActionResult Something()
|
||||
{
|
||||
return new ContentResult
|
||||
{
|
||||
Content = "Hello World From Content"
|
||||
};
|
||||
}
|
||||
|
||||
public ActionResult Hello()
|
||||
{
|
||||
return Content("Hello World");
|
||||
}
|
||||
|
||||
public void Raw()
|
||||
{
|
||||
HttpContext.Response.WriteAsync("Hello World raw");
|
||||
}
|
||||
|
||||
public ActionResult Language()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
[Produces("application/json", "application/xml", "application/custom", "text/json", Type = typeof(User))]
|
||||
public object ReturnUser()
|
||||
{
|
||||
return CreateUser();
|
||||
}
|
||||
|
||||
public User CreateUser()
|
||||
{
|
||||
User user = new User()
|
||||
{
|
||||
Name = "My name",
|
||||
Address = "My address",
|
||||
Alive = true,
|
||||
Age = 13,
|
||||
GPA = 13.37M,
|
||||
Dependent = new User()
|
||||
{
|
||||
Name = "Dependents name",
|
||||
Address = "Dependents address",
|
||||
Alive = false,
|
||||
},
|
||||
Profession = "Software Engineer",
|
||||
About = "I like playing Football"
|
||||
};
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
[HttpGet("/AttributeRouting/{other}", Order = 0)]
|
||||
public string LowerPrecedence(string param)
|
||||
{
|
||||
return "Lower";
|
||||
}
|
||||
|
||||
// Normally this route would be tried before the one above
|
||||
// as it is more explicit (doesn't have a parameter), but
|
||||
// due to the fact that it has a higher order, it will be
|
||||
// tried after the route above.
|
||||
[HttpGet("/AttributeRouting/HigherPrecedence", Order = 1)]
|
||||
public string HigherOrder()
|
||||
{
|
||||
return "Higher";
|
||||
}
|
||||
|
||||
// Both routes have the same template, which would make
|
||||
// them ambiguous, but the order we defined in the routes
|
||||
// disambiguates them.
|
||||
[HttpGet("/AttributeRouting/SameTemplate", Order = 0)]
|
||||
public string SameTemplateHigherOrderPrecedence()
|
||||
{
|
||||
return "HigherOrderPrecedence";
|
||||
}
|
||||
|
||||
[HttpGet("/AttributeRouting/SameTemplate", Order = 1)]
|
||||
public string SameTemplateLowerOrderPrecedence()
|
||||
{
|
||||
return "LowerOrderPrecedence";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Action that exercises default view names.
|
||||
/// </summary>
|
||||
public ActionResult MyView()
|
||||
{
|
||||
return View(CreateUser());
|
||||
}
|
||||
|
||||
public ActionResult FlushPoint()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
private static IEnumerable<SelectListItem> CreateAddresses()
|
||||
{
|
||||
var addresses = new[]
|
||||
{
|
||||
"121 Fake St., Redmond, WA, USA",
|
||||
"123 Fake St., Redmond, WA, USA",
|
||||
"125 Fake St., Redmond, WA, USA",
|
||||
"127 Fake St., Redmond, WA, USA",
|
||||
"129 Fake St., Redmond, WA, USA",
|
||||
"131 Fake St., Redmond, WA, USA",
|
||||
};
|
||||
|
||||
return new SelectList(addresses);
|
||||
}
|
||||
|
||||
private static IEnumerable<SelectListItem> CreateAges()
|
||||
{
|
||||
var ages = Enumerable.Range(27, 47).Select(age => new { Age = age, Display = age.ToString("####"), });
|
||||
|
||||
return new SelectList(ages, dataValueField: "Age", dataTextField: "Display");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Mvc;
|
||||
|
||||
namespace MvcSample.Web
|
||||
{
|
||||
public class LinkController : Controller
|
||||
{
|
||||
public ActionResult Details()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
public string About()
|
||||
{
|
||||
return Url.Action(null);
|
||||
}
|
||||
|
||||
public string Get()
|
||||
{
|
||||
// Creates a url like: http://localhost:58195/Home/Create#CoolBeans!
|
||||
return Url.RouteUrl(null, new { controller = "Home", action = "Create" }, protocol: "http", host: null, fragment: "CoolBeans!");
|
||||
}
|
||||
|
||||
public string Link1()
|
||||
{
|
||||
return Url.Action("Index", "Home");
|
||||
}
|
||||
|
||||
public string Link2()
|
||||
{
|
||||
return Url.Action("Link2");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace MvcSample.Web
|
||||
{
|
||||
public class Address
|
||||
{
|
||||
[Required]
|
||||
public string Street { get; set; }
|
||||
|
||||
[Required]
|
||||
public string City { get; set; }
|
||||
|
||||
[Required]
|
||||
public string State { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ZipCode { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MvcSample.Web.ApiExplorerSamples
|
||||
{
|
||||
public class Order
|
||||
{
|
||||
[FromRoute]
|
||||
public int AccountId { get; set; }
|
||||
|
||||
[FromBody]
|
||||
public List<OrderItem> Items { get; set; }
|
||||
|
||||
[FromQuery]
|
||||
public bool? IncludeWarranty { get; set; }
|
||||
|
||||
public class OrderItem
|
||||
{
|
||||
public int ProductId { get; set; }
|
||||
|
||||
public int Quantity { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace MvcSample.Web.ApiExplorerSamples
|
||||
{
|
||||
public class Product
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
public decimal Price { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace MvcSample.Web.ApiExplorerSamples
|
||||
{
|
||||
public class ProductChangeDTO
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Description { get; set; }
|
||||
|
||||
public decimal Price { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
namespace MvcSample.Web.ApiExplorerSamples
|
||||
{
|
||||
public class ProductOrderConfirmation
|
||||
{
|
||||
public Product Product { get; set; }
|
||||
|
||||
public decimal PricePerUnit { get; set; }
|
||||
|
||||
public int Quantity { get; set; }
|
||||
|
||||
public decimal TotalPrice { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Mvc;
|
||||
|
||||
namespace MvcSample.Web.ApiExplorerSamples
|
||||
{
|
||||
public class UpdateProductDTO
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[FromBody]
|
||||
public Product Product { get; set; }
|
||||
|
||||
[FromHeader(Name = "Admin-User")]
|
||||
public string AdminId { get; set; }
|
||||
|
||||
public string Comments { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace MvcSample.Web
|
||||
{
|
||||
public class Job
|
||||
{
|
||||
[Required]
|
||||
public string JobTitle { get; set; }
|
||||
|
||||
[Required]
|
||||
public string EmployerName { get; set; }
|
||||
|
||||
[Required]
|
||||
public int Years { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace MvcSample.Web
|
||||
{
|
||||
public class Person
|
||||
{
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Required]
|
||||
public Address Address { get; set; }
|
||||
|
||||
[Required]
|
||||
public IEnumerable<Job> PastJobs { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
using System;
|
||||
|
||||
namespace MvcSample.Web
|
||||
{
|
||||
public class Product
|
||||
{
|
||||
public int SampleInt { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MvcSample.Web.Models
|
||||
{
|
||||
public enum TestEnum
|
||||
{
|
||||
Zero = 0,
|
||||
[Display(GroupName = "Primes")]
|
||||
One = 1,
|
||||
[Display(GroupName = "Evens", Name = "Dos")]
|
||||
Two = 2,
|
||||
[Display(GroupName = "Primes")]
|
||||
Three = 3,
|
||||
[Display(Name = "4th")]
|
||||
Four = 4
|
||||
}
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace MvcSample.Web.Models
|
||||
{
|
||||
[DisplayColumn("Name")]
|
||||
public class User
|
||||
{
|
||||
public User()
|
||||
{
|
||||
OwnedAddresses = new List<string>();
|
||||
ParentsAges = new List<int>();
|
||||
}
|
||||
|
||||
[Required]
|
||||
[MinLength(4)]
|
||||
public string Name { get; set; }
|
||||
public string Address { get; set; }
|
||||
[Range(27, 70)]
|
||||
public int Age { get; set; }
|
||||
public decimal GPA { get; set; }
|
||||
public User Dependent { get; set; }
|
||||
public bool Alive { get; set; }
|
||||
[DisplayFormat(ConvertEmptyStringToNull = true, NullDisplayText = "You can explain about your profession")]
|
||||
public string Profession { get; set; }
|
||||
public string About { get; set; }
|
||||
public string Log { get; set; }
|
||||
public IEnumerable<string> OwnedAddresses { get; private set; }
|
||||
public TestEnum EnumInformation { get; set; }
|
||||
|
||||
// This does not bind correctly. Only gets highest value.
|
||||
public List<int> ParentsAges { get; private set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.ActionConstraints;
|
||||
using Microsoft.AspNet.Mvc.WebApiCompatShim;
|
||||
using MvcSample.Web.Models;
|
||||
|
||||
namespace MvcSample.Web
|
||||
{
|
||||
public class OverloadController
|
||||
{
|
||||
// All results implement IActionResult so it can be safely returned.
|
||||
public IActionResult Get()
|
||||
{
|
||||
return Content("Get()");
|
||||
}
|
||||
|
||||
[Overload]
|
||||
public ActionResult Get(int id)
|
||||
{
|
||||
return Content("Get(id)");
|
||||
}
|
||||
|
||||
[Overload]
|
||||
public ActionResult Get(int id, string name)
|
||||
{
|
||||
return Content("Get(id, name)");
|
||||
}
|
||||
|
||||
[Overload]
|
||||
public ActionResult Get(string bleh)
|
||||
{
|
||||
return Content("Get(bleh)");
|
||||
}
|
||||
|
||||
public ActionResult WithUser()
|
||||
{
|
||||
return Content("WithUser()");
|
||||
}
|
||||
|
||||
// Called for all posts regardless of values provided
|
||||
[HttpPost]
|
||||
public ActionResult WithUser(User user)
|
||||
{
|
||||
return Content("WithUser(User)");
|
||||
}
|
||||
|
||||
public ActionResult WithUser(int projectId, User user)
|
||||
{
|
||||
return Content("WithUser(int, User)");
|
||||
}
|
||||
|
||||
private ContentResult Content(string content)
|
||||
{
|
||||
var result = new ContentResult
|
||||
{
|
||||
Content = content,
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private class OverloadAttribute : Attribute, IActionConstraintFactory
|
||||
{
|
||||
public IActionConstraint CreateInstance(IServiceProvider services)
|
||||
{
|
||||
return new OverloadActionConstraint();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
|
||||
namespace MvcSample.Web.Services
|
||||
{
|
||||
public interface ITestService
|
||||
{
|
||||
string GetFoo();
|
||||
}
|
||||
|
||||
|
||||
public class TestService : ITestService
|
||||
{
|
||||
public string GetFoo()
|
||||
{
|
||||
return "Hello world " + DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Filters;
|
||||
|
||||
namespace MvcSample.Web
|
||||
{
|
||||
public class SimplePocoController : IActionFilter, IResultFilter
|
||||
{
|
||||
private Stopwatch _timer;
|
||||
|
||||
public string Index()
|
||||
{
|
||||
return "Hello world";
|
||||
}
|
||||
|
||||
public void OnActionExecuting(ActionExecutingContext context)
|
||||
{
|
||||
_timer = Stopwatch.StartNew();
|
||||
}
|
||||
|
||||
public void OnActionExecuted(ActionExecutedContext context)
|
||||
{
|
||||
var time = _timer.ElapsedMilliseconds;
|
||||
context.HttpContext.Response.Headers.Add(
|
||||
"ActionElapsedTime",
|
||||
new string[] { time.ToString(CultureInfo.InvariantCulture) + " ms" });
|
||||
}
|
||||
|
||||
public void OnResultExecuting(ResultExecutingContext context)
|
||||
{
|
||||
_timer = Stopwatch.StartNew();
|
||||
}
|
||||
|
||||
public void OnResultExecuted(ResultExecutedContext context)
|
||||
{
|
||||
var time = _timer.ElapsedMilliseconds;
|
||||
context.HttpContext.Response.Headers.Add(
|
||||
"ResultElapsedTime",
|
||||
new string[] { time.ToString(CultureInfo.InvariantCulture) + " ms" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Mvc;
|
||||
|
||||
namespace MvcSample.Web
|
||||
{
|
||||
[AutoGenerateRouteNames]
|
||||
[Route("api/REST")]
|
||||
public class SimpleRest : Controller
|
||||
{
|
||||
[HttpGet]
|
||||
public string ThisIsAGetMethod()
|
||||
{
|
||||
return "Get method";
|
||||
}
|
||||
|
||||
[HttpGet("[action]")]
|
||||
public string GetOtherThing()
|
||||
{
|
||||
// Will be GetOtherThing
|
||||
return (string)RouteData.Values["action"];
|
||||
}
|
||||
|
||||
[HttpGet("Link")]
|
||||
public string GenerateLink(string action = null, string controller = null)
|
||||
{
|
||||
return Url.Action(action, controller);
|
||||
}
|
||||
|
||||
[HttpGet("Link/{name}")]
|
||||
public string GenerateLinkByName(string name = null)
|
||||
{
|
||||
// This action leverages [AutoGenerateRouteNames]. Try a URL like api/Rest/Link/SimpleRest_ThisIsAGetMethod
|
||||
// which matches the auto-generated name for the ThisIsAGetMethod action.
|
||||
return Url.RouteUrl(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Localization;
|
||||
using Microsoft.AspNet.Mvc;
|
||||
using Microsoft.AspNet.Mvc.Razor;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MvcSample.Web.Filters;
|
||||
using MvcSample.Web.Services;
|
||||
|
||||
namespace MvcSample.Web
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public IServiceProvider ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddCaching();
|
||||
services.AddSession();
|
||||
|
||||
services.AddMvc(options =>
|
||||
{
|
||||
options.Filters.Add(typeof(PassThroughAttribute), order: 17);
|
||||
options.Filters.Add(new FormatFilterAttribute());
|
||||
})
|
||||
.AddXmlDataContractSerializerFormatters()
|
||||
.AddViewLocalization(LanguageViewLocationExpanderFormat.SubFolder);
|
||||
|
||||
services.AddSingleton<PassThroughAttribute>();
|
||||
services.AddSingleton<UserNameService>();
|
||||
services.AddTransient<ITestService, TestService>();
|
||||
|
||||
return services.BuildServiceProvider();
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
|
||||
{
|
||||
loggerFactory.AddConsole((category, level) =>
|
||||
{
|
||||
if (category.StartsWith("Microsoft."))
|
||||
{
|
||||
return level >= LogLevel.Information;
|
||||
}
|
||||
|
||||
return level >= LogLevel.Verbose;
|
||||
});
|
||||
|
||||
app.UseStatusCodePages();
|
||||
app.UseFileServer();
|
||||
|
||||
app.UseRequestLocalization(new RequestCulture("en-US"));
|
||||
|
||||
app.UseSession();
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
routes.MapRoute("areaRoute", "{area:exists}/{controller}/{action}");
|
||||
routes.MapRoute(
|
||||
"controllerActionRoute",
|
||||
"{controller}/{action}",
|
||||
new { controller = "Home", action = "Index" },
|
||||
constraints: null,
|
||||
dataTokens: new { NameSpace = "default" });
|
||||
|
||||
routes.MapRoute(
|
||||
"controllerRoute",
|
||||
"{controller}",
|
||||
new { controller = "Home" });
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
#if VIEWMETADATA
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class ViewMetadata
|
||||
{
|
||||
public static Dictionary<string, Type> Metadata
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Dictionary<string, Type>
|
||||
{
|
||||
{
|
||||
"~/Views/Home/MyView.cshtml",
|
||||
typeof(MvcSample.Views.MyView)
|
||||
},
|
||||
{
|
||||
"~/Views/Shared/_Layout.cshtml",
|
||||
typeof(MvcSample.Views.Layout)
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
@using Microsoft.AspNet.Mvc.ApiExplorer
|
||||
@model IReadOnlyList<ApiDescriptionGroup>
|
||||
|
||||
@section header
|
||||
{
|
||||
<link rel="stylesheet" href="~/Content/api-description.css" />
|
||||
}
|
||||
|
||||
<div style="padding: 50px 0px 0px 0px">
|
||||
|
||||
@foreach (var group in Model)
|
||||
{
|
||||
<div class="row">
|
||||
<h1>Group: @group.GroupName</h1>
|
||||
|
||||
@foreach (var item in group.Items)
|
||||
{
|
||||
await Html.RenderPartialAsync("_ApiDescription", item);
|
||||
}
|
||||
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
@using Microsoft.AspNet.Mvc.ApiExplorer
|
||||
@model ApiDescription
|
||||
|
||||
<div class="api-description">
|
||||
<h4>
|
||||
<span title="@Model.ActionDescriptor.DisplayName">
|
||||
@(Model.HttpMethod ?? "*") - @(Model.RelativePath ?? "Unknown Url")
|
||||
</span>
|
||||
</h4>
|
||||
<hr />
|
||||
|
||||
<h5>Parameters:</h5>
|
||||
@if (Model.ParameterDescriptions.Count > 0)
|
||||
{
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Name</td>
|
||||
<td>Data Type</td>
|
||||
<td>Source</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var parameter in Model.ParameterDescriptions)
|
||||
{
|
||||
<tr>
|
||||
<td>@parameter.Name</td>
|
||||
<td>@(parameter.Type?.FullName ?? "Unknown Type")</td>
|
||||
<td>@parameter.Source.Id</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
|
||||
<h5>Response Formats</h5>
|
||||
@if (Model.SupportedResponseFormats.Count > 0)
|
||||
{
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<td>Data Type</td>
|
||||
<td>Media Type</td>
|
||||
<td>Formatter</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var response in Model.SupportedResponseFormats)
|
||||
{
|
||||
<tr>
|
||||
<td>@Model.ResponseType.FullName</td>
|
||||
<td>@response.MediaType.ToString()</td>
|
||||
<td>@response.Formatter.GetType().Name</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>JQuery FormUrlEncoded example</title>
|
||||
<script src="~/lib/jquery/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="~/Scripts/MVC.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
$('#personButton').click(function () {
|
||||
var data = {
|
||||
Name: 'SamplePerson',
|
||||
Address: {
|
||||
Street: 'SampleStreet',
|
||||
City: "SampleCity",
|
||||
State: "SampleState",
|
||||
ZipCode: 11
|
||||
},
|
||||
PastJobs: [
|
||||
{
|
||||
JobTitle: "SampleJob1",
|
||||
EmployerName: 'Employer1',
|
||||
Years: 2
|
||||
},
|
||||
{
|
||||
JobTitle: "SampleJob2",
|
||||
EmployerName: 'Employer2',
|
||||
Years: 4
|
||||
},
|
||||
{
|
||||
JobTitle: "SampleJob3",
|
||||
EmployerName: 'Employer3',
|
||||
Years: 1
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
$.post('@Url.Action("IsValidPerson", "FormUrlEncoded")', MVC.stringify(data))
|
||||
.done(function (result) {
|
||||
if (result)
|
||||
{
|
||||
$("#validPerson").html("The submitted data belongs to a valid person.");
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#validPerson").html("The submitted data is invalid.");
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<button id="personButton" type="button">Click here to post person data</button><br /><br />
|
||||
<p id="validPerson"></p>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,127 +0,0 @@
|
|||
@using MvcSample.Web.Models
|
||||
@using Microsoft.AspNet.Mvc.ModelBinding
|
||||
@model User
|
||||
@{
|
||||
ViewBag.Title = (Model == null && ViewData.ModelState.Count == 0) ? "Create Page" : "Edit Page";
|
||||
if (ViewBag.Gift == null)
|
||||
{
|
||||
ViewBag.Gift = "nothing";
|
||||
}
|
||||
}
|
||||
|
||||
<div class="row">
|
||||
<h2 title="@ViewBag.Title" class="@ViewBag.NullValue">@ViewBag.Title</h2>
|
||||
<h3 title="Thanks" class="@ViewBag.NullValue">Thanks for @ViewBag.Gift</h3>
|
||||
@if (Model == null)
|
||||
{
|
||||
<h4 title ="Null Model" class="@ViewBag.NullValue">Howdy, your model is null.</h4>
|
||||
}
|
||||
else
|
||||
{
|
||||
<h4 title="@Model.Name" class="@ViewBag.NullValue">Hello @Html.DisplayTextFor(model => model.Name)! Happy @(Model.Age)th birthday.</h4>
|
||||
}
|
||||
|
||||
@{
|
||||
var metadata = ViewData.ModelMetadata;
|
||||
if (metadata != null)
|
||||
{
|
||||
var typeName = metadata.ModelType.Name;
|
||||
var description = metadata.Description ?? "no description";
|
||||
<p>@typeName has description '@description' and contains</p>
|
||||
<ul>
|
||||
@foreach (var property in metadata.Properties)
|
||||
{
|
||||
<li>Property @property.PropertyName is type @property.ModelType.Name and '@(property.Description ?? "no description")'</li>
|
||||
}
|
||||
</ul>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div style="float: left; border: thick solid limegreen; padding-right: 10px">
|
||||
@using (Html.BeginForm(controllerName: "Home", actionName: "Edit", method: FormMethod.Post))
|
||||
{
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<label class="control-label col-md-2" for="Name">Model.Name</label>
|
||||
</td>
|
||||
<td>
|
||||
@Html.TextBox("Name")
|
||||
</td>
|
||||
<td>
|
||||
@Html.ValidationMessage("Name.Name", "Name is required", new { @style = "font-weight: bold" })
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label class="control-label col-md-2" for="Address">Model.Address</label>
|
||||
</td>
|
||||
<td>
|
||||
@Html.DropDownList("Address", "Select an Address")
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label class="control-label col-md-2" for="Age">Model.Age</label>
|
||||
</td>
|
||||
<td>
|
||||
@Html.DropDownListFor(model => model.Age, (IEnumerable<SelectListItem>)ViewBag.Ages, htmlAttributes: new { @class = "form-control" })
|
||||
</td>
|
||||
<td>
|
||||
@Html.ValidationMessageFor(model => model.Age, "Age must be between 27 and 70", new { @style = "font-weight: bold" })
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label class="control-label col-md-2">Model.Profession</label>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" id="@Html.IdFor(model => model.Profession)" name="Profession" value='@Html.DisplayText("Profession")' />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label class="control-label col-md-2">Model.About</label>
|
||||
</td>
|
||||
<td>
|
||||
@Html.TextArea("About", "You can explain about your hobbies, work etc.", 5, 40, htmlAttributes: new { style = "font-weight:bold" })
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label class="control-label col-md-2" for="OwnedAddresses">Model.OwnedAddresses</label>
|
||||
</td>
|
||||
<td>
|
||||
@Html.Editor("OwnedAddresses")
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label class="control-label col-md-2" for="ParentsAges">Model.ParentsAges</label>
|
||||
</td>
|
||||
<td>
|
||||
@Html.ListBoxFor(model => model.ParentsAges, (IEnumerable<SelectListItem>)ViewBag.Ages, htmlAttributes: new { @class = "form-control" })
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<label class="control-label col-md-2" for="Name">Model.EnumInformation</label>
|
||||
</td>
|
||||
<td>
|
||||
@Html.DropDownList("EnumInformation", Html.GetEnumSelectList<TestEnum>())
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="submit" value="Save" class="btn btn-default" style="margin-left: 10px" />
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
@using System.Collections.Generic
|
||||
@model IEnumerable<string>
|
||||
|
||||
@Html.ListBox(null, (IEnumerable<SelectListItem>)ViewBag.Address)
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
@{
|
||||
Layout = "/Views/Shared/_FlushPointLayout.cshtml";
|
||||
ViewBag.Title = "Home Page";
|
||||
}
|
||||
|
||||
@section content
|
||||
{
|
||||
<div class="jumbotron">
|
||||
<h1>ASP.NET</h1>
|
||||
<p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p>
|
||||
<p><a href="http://asp.net" class="btn btn-primary btn-lg">Learn more »</a></p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<h2>Getting started</h2>
|
||||
<p>
|
||||
ASP.NET MVC gives you a powerful, patterns-based way to build dynamic websites that
|
||||
enables a clean separation of concerns and gives you full control over markup
|
||||
for enjoyable, agile development.
|
||||
</p>
|
||||
<p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301865">Learn more »</a></p>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h2>Get more libraries</h2>
|
||||
<p>NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.</p>
|
||||
<p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301866">Learn more »</a></p>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h2>Web Hosting</h2>
|
||||
<p>You can easily find a web hosting company that offers the right mix of features and price for your applications.</p>
|
||||
<p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301867">Learn more »</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<address>
|
||||
One Microsoft Way<br />
|
||||
Redmond, WA 98052-6399<br />
|
||||
<abbr title="Phone">P:</abbr>
|
||||
425.555.0100
|
||||
</address>
|
||||
|
||||
<address>
|
||||
<strong>Support:</strong> <a href="mailto:Support@example.com">Support@example.com</a><br />
|
||||
<strong>Marketing:</strong> <a href="mailto:Marketing@example.com">Marketing@example.com</a>
|
||||
</address>
|
||||
|
||||
@await FlushAsync()
|
||||
@{
|
||||
await Task.Delay(TimeSpan.FromSeconds(1));
|
||||
}
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
Integer pharetra dignissim tortor, quis facilisis tellus faucibus in. Phasellus fringilla pellentesque justo eu tempor. Sed eget viverra lacus, eget gravida turpis. Donec dapibus sodales leo, non pharetra lacus volutpat quis. Quisque et auctor nulla. Nunc a orci ut libero luctus ornare ut eget erat. Integer eu risus tempor, scelerisque lacus nec, dignissim nisl. Ut ac leo nec velit tempus fringilla. Phasellus id nisi tortor. Aliquam magna nunc, congue eget sem quis, porta accumsan magna. Sed sit amet dapibus sem, placerat malesuada felis. Quisque vel dui ut est luctus congue.
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
Aliquam nec elementum orci, ut interdum mi. Sed lorem lacus, malesuada in nisi a, auctor lobortis ipsum. Ut id erat suscipit, pharetra dui eu, sodales erat. Duis nibh turpis, vestibulum sit amet leo vitae, faucibus iaculis lectus. Nam lacinia purus fringilla dolor dictum posuere nec in libero. Integer id tempor elit. Mauris adipiscing ut sem id tincidunt. Cras turpis elit, dignissim vitae adipiscing vitae, ullamcorper in felis. Nullam et adipiscing neque. Integer ullamcorper eget tortor in sodales. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse pretium tristique libero, ut gravida est placerat quis. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed sed lorem cursus, porttitor nibh eu, bibendum turpis.
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
@using MvcSample.Web.Services
|
||||
@inject MvcSample.Web.Services.ITestService MyService
|
||||
@inject ITestService MyService2
|
||||
|
||||
@MyService.GetFoo()
|
||||
@MyService2.GetFoo()
|
||||
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<ul>
|
||||
<li>COLOR</li>
|
||||
<li>HUMOR</li>
|
||||
<li>ITEMIZE</li>
|
||||
</ul>
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
@*
|
||||
For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860
|
||||
*@
|
||||
@{
|
||||
// ViewBag.Title = "Home Page";
|
||||
}
|
||||
|
||||
@using MvcSample.Web.Models
|
||||
@model User
|
||||
|
||||
<div class="row">
|
||||
<div style="float: left; border: 5px solid lightblue; margin: 5px; padding: 7px;">
|
||||
EditorForModel:
|
||||
@Html.EditorForModel()
|
||||
</div>
|
||||
<div style="float: left; border: 5px solid blue; margin: 5px; padding: 7px;">
|
||||
Editor of empty string:
|
||||
@Html.Editor("")
|
||||
</div>
|
||||
<div style="float: left; border: 5px solid darkblue; margin: 5px; padding: 7px;">
|
||||
EditorFor of identity expression:
|
||||
@Html.EditorFor(m => m)
|
||||
</div>
|
||||
|
||||
<div style="float: left; border: 5px solid red; margin: 5px; padding: 7px;">
|
||||
DisplayForModel:
|
||||
'@Html.DisplayForModel()'
|
||||
</div>
|
||||
|
||||
<div style="float: left; border: 5px solid green; margin: 5px; padding: 7px;">
|
||||
Display:
|
||||
for name '@Html.Display("Name")'
|
||||
and alive '@Html.Display("Alive")'
|
||||
</div>
|
||||
|
||||
<div style="float: left; border: 5px solid cyan; margin: 5px; padding: 7px;">
|
||||
Editor:
|
||||
for name @Html.Editor("Name")
|
||||
alive @Html.Editor("Alive")
|
||||
and alive expression @Html.EditorFor(m => m.Alive)
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>File Upload Successful</title>
|
||||
</head>
|
||||
<body>
|
||||
<h2>File upload successful.</h2>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
<style>
|
||||
.validationSummary {
|
||||
display: inline-block;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
border: 1px solid black;
|
||||
background-color: #e4e3e3;
|
||||
}
|
||||
</style>
|
||||
|
||||
<h1>ValidationSummary Test Page.</h1>
|
||||
<p>Below are all overloads for Html.ValidationSummary. You should see 8 validation summary titles and 4 validation summary error messages.</p>
|
||||
<br />
|
||||
|
||||
<section class="validationSummary">
|
||||
@Html.ValidationSummary()
|
||||
@Html.ValidationSummary(excludePropertyErrors: true)
|
||||
@Html.ValidationSummary(message: "Hello from validation message summary 1.")
|
||||
@Html.ValidationSummary(message: "Hello from validation message summary 2.", tag: "h2")
|
||||
@Html.ValidationSummary(excludePropertyErrors: true, message: "Hello from validation message summary 3")
|
||||
@Html.ValidationSummary(message: "Hello from validation message summary 4", htmlAttributes: new { style = "color: red" })
|
||||
@Html.ValidationSummary(message: "Hello from validation message summary 5", htmlAttributes: new { style = "color: red" }, tag: "h2")
|
||||
@Html.ValidationSummary(excludePropertyErrors: true, message: "Hello from validation message summary 6", tag: "h2")
|
||||
@Html.ValidationSummary(excludePropertyErrors: true, message: "Hello from validation message summary 7", htmlAttributes: new { style = "color: green" })
|
||||
@Html.ValidationSummary(message: "Hello from validation message summary 8", htmlAttributes: new Dictionary<string, object> { { "style", "color: blue" } }, tag: "h2")
|
||||
</section>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<ul>
|
||||
<li>COLOUR</li>
|
||||
<li>HUMOUR</li>
|
||||
<li>ITEMISE</li>
|
||||
</ul>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<ul>
|
||||
<li>COULEUR</li>
|
||||
<li>HUMOUR</li>
|
||||
<li>DÉTAILLER</li>
|
||||
</ul>
|
||||
|
|
@ -1,142 +0,0 @@
|
|||
<head>
|
||||
<script src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.0.min.js"></script>
|
||||
<script>
|
||||
$(function () {
|
||||
var currentObj = {
|
||||
"Name": "John",
|
||||
"Orders": [{"OrderName": "Order1"},
|
||||
{"OrderName": "Order2"}]
|
||||
};
|
||||
$('#currentLabel').text(JSON.stringify(currentObj))
|
||||
|
||||
$('#addOrder').on("click", function () {
|
||||
var obj = [{
|
||||
"op": "Add",
|
||||
"path": "Customer/Orders/2",
|
||||
"value": { "OrderName": "Name3" }
|
||||
}]
|
||||
$.ajax({
|
||||
url: 'jsonpatch',
|
||||
type: 'PATCH',
|
||||
data: JSON.stringify(obj),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json-patch+json',
|
||||
success: function (data) {
|
||||
$('#addLabel').text(JSON.stringify(data))
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#invalidAddOrder').on("click", function () {
|
||||
var obj = [{
|
||||
"op": "Add",
|
||||
"path": "Customer/Orders/5",
|
||||
"value": { "OrderName": "Name5" }
|
||||
}]
|
||||
$.ajax({
|
||||
url: 'jsonpatch',
|
||||
type: 'PATCH',
|
||||
data: JSON.stringify(obj),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json-patch+json',
|
||||
success: function (data) {
|
||||
$('#invalidAddLabel').text(data)
|
||||
},
|
||||
error: function (request, status, error) {
|
||||
$('#invalidAddLabel').text(error)
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$('#removeOrder').on("click", function () {
|
||||
var obj = [{
|
||||
"op": "Remove",
|
||||
"path": "Customer/Name"
|
||||
}]
|
||||
$.ajax({
|
||||
url: 'jsonpatch',
|
||||
type: 'PATCH',
|
||||
data: JSON.stringify(obj),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json-patch+json',
|
||||
success: function (data) {
|
||||
$('#removeLabel').text(JSON.stringify(data))
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#moveOrder').on("click", function () {
|
||||
var obj = [{
|
||||
"op": "Move",
|
||||
"from": "Customer/Orders/0",
|
||||
"path": "Customer/Orders/1"
|
||||
}]
|
||||
$.ajax({
|
||||
url: 'jsonpatch',
|
||||
type: 'PATCH',
|
||||
data: JSON.stringify(obj),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json-patch+json',
|
||||
success: function (data) {
|
||||
$('#moveLabel').text(JSON.stringify(data))
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('#replaceOrder').on("click", function () {
|
||||
var obj = [{
|
||||
"op": "Replace",
|
||||
"path": "Customer/Name",
|
||||
"value": "ReplacedName"
|
||||
}]
|
||||
$.ajax({
|
||||
url: 'jsonpatch',
|
||||
type: 'PATCH',
|
||||
data: JSON.stringify(obj),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json-patch+json',
|
||||
success: function (data) {
|
||||
$('#replaceLabel').text(JSON.stringify(data))
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<label>Current Customer</label>
|
||||
<br />
|
||||
<label id="currentLabel" name="currentLabel"></label>
|
||||
<br />
|
||||
</div>
|
||||
<div>
|
||||
<button id="addOrder" type="submit" class="btn btn-primary"> Add </button>
|
||||
<br />
|
||||
<label id="addLabel" name="addLabel"></label>
|
||||
<br />
|
||||
</div>
|
||||
<div>
|
||||
<button id="invalidAddOrder" type="submit" class="btn btn-primary"> Invalid Add </button>
|
||||
<br />
|
||||
<label id="invalidAddLabel" name="invalidAddLabel"></label>
|
||||
<br />
|
||||
</div>
|
||||
<div>
|
||||
<button id="removeOrder" type="submit" class="btn btn-primary"> Remove </button>
|
||||
<br />
|
||||
<label id="removeLabel" name="removeLabel"></label>
|
||||
</div>
|
||||
<div>
|
||||
<button id="moveOrder" type="submit" class="btn btn-primary"> Move </button>
|
||||
<br />
|
||||
<label id="moveLabel" name="moveLabel"></label>
|
||||
<br />
|
||||
</div>
|
||||
<div>
|
||||
<button id="replaceOrder" type="submit" class="btn btn-primary"> Replace </button>
|
||||
<br />
|
||||
<label id="replaceLabel" name="replaceLabel"></label>
|
||||
</div>
|
||||
</body>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
|
||||
|
||||
@Url.Action("About")
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
@model string[]
|
||||
|
||||
<div style="width: 300px; height: 250px; padding: 0px 10px;">
|
||||
<h4>@ViewBag.Title</h4>
|
||||
@foreach (var tag in Model)
|
||||
{
|
||||
<span>@tag</span>
|
||||
}
|
||||
</div>
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
@* Override default Decimal template to display value in bold. *@
|
||||
@using System.Globalization
|
||||
|
||||
@functions {
|
||||
private object FormattedValue {
|
||||
get {
|
||||
if (ViewData.TemplateInfo.FormattedModelValue == ViewData.ModelExplorer.Model) {
|
||||
return String.Format(CultureInfo.CurrentCulture, "{0:0.00}", ViewData.ModelExplorer.Model);
|
||||
}
|
||||
return ViewData.TemplateInfo.FormattedModelValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
<b>@Html.Encode(FormattedValue)</b>
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
@* Override default Decimal template to display value in bold and ignore Html attributes in ViewData. *@
|
||||
@using System.Globalization
|
||||
|
||||
@functions {
|
||||
private object FormattedValue {
|
||||
get {
|
||||
if (ViewData.TemplateInfo.FormattedModelValue == ViewData.ModelExplorer.Model) {
|
||||
return string.Format(CultureInfo.CurrentCulture, "{0:0.00}", ViewData.ModelExplorer.Model);
|
||||
}
|
||||
return ViewData.TemplateInfo.FormattedModelValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Html.TextBox(
|
||||
expression: null,
|
||||
value: FormattedValue,
|
||||
htmlAttributes: new { @class = "text-box single-line", style = "font-weight: bold", })
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
@using MvcSample.Web.Models
|
||||
@model User
|
||||
|
||||
<strong>Hello @(Model?.Name) from Partial</strong>
|
||||
|
||||
<a href="@Url.Action("Create", "Home")">Create Something!</a>
|
||||
|
|
@ -1,420 +0,0 @@
|
|||
@using MvcSample.Web.Models
|
||||
@model User
|
||||
@{
|
||||
ViewBag.Title = "Home Page";
|
||||
string nullValue = null;
|
||||
|
||||
ViewBag.Anon = new
|
||||
{
|
||||
Name = "FirstName LastName",
|
||||
Address = new { Street = "123 Fake St.", City = "Redmond", State = "WA", Country = "USA", },
|
||||
};
|
||||
}
|
||||
|
||||
@section header {
|
||||
<style type="text/css">
|
||||
#qux {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#qux.foo {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
}
|
||||
|
||||
@section footer {
|
||||
<script src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.0.min.js"></script>
|
||||
<script>
|
||||
$(function () {
|
||||
$("#qux").fadeIn(3000, function () {
|
||||
$(this).addClass("foo")
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
||||
|
||||
@functions {
|
||||
public Task<string> AsyncValueRetrieval()
|
||||
{
|
||||
return Task.FromResult("Hello World");
|
||||
}
|
||||
|
||||
public Task RenderHelloWorldPartial(User model)
|
||||
{
|
||||
// Imagine this method was a super complex method that was used as a helper method.
|
||||
return Html.RenderPartialAsync("HelloWorldPartial", model);
|
||||
}
|
||||
}
|
||||
|
||||
<div class="jumbotron">
|
||||
<h1>ASP.NET</h1>
|
||||
<p class="lead">ASP.NET is a free web framework for building great Web sites and Web applications using HTML, CSS and JavaScript.</p>
|
||||
<p><a href="http://asp.net" class="btn btn-primary btn-large">Learn more »</a></p>
|
||||
<h3 style="color: red">@ViewBag.TempData<br/>@TempData["tempData"]</h3>
|
||||
File Upload Demo: <br/>
|
||||
<form action="Home/PostFile" method="post" enctype="multipart/form-data">
|
||||
<input type="file" name="files" id="file1" />
|
||||
<input type="file" name="files" id="file2" />
|
||||
<input type="submit" value="submit" />
|
||||
</form>
|
||||
</div>
|
||||
<div class="row">
|
||||
<h3 title="@(Model?.Name)" class="@nullValue">Hello @Html.DisplayTextFor(User => User)! Happy @(Model?.Age) birthday.</h3>
|
||||
<h3 id="qux">This value was retrieved asynchronously: @(await AsyncValueRetrieval())</h3>
|
||||
<h3>Partial Async: @await Html.PartialAsync("HelloWorldPartial", Model)</h3>
|
||||
<h3>
|
||||
Render Partial Async (Custom model): @{ await RenderHelloWorldPartial(new User()
|
||||
{
|
||||
Name="Bob"
|
||||
});
|
||||
}
|
||||
</h3>
|
||||
|
||||
<div class="col-md-4">
|
||||
<h2>Book a flight</h2>
|
||||
<p>
|
||||
Go to our cool travel reservation system.
|
||||
</p>
|
||||
<p>@Html.ActionLink("Reserve Now", "Fly", "Flight", new { area = "Travel" }, new { @class = "btn btn-default" })</p>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h2>Get more libraries</h2>
|
||||
<p>NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.</p>
|
||||
<p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301866">Learn more »</a></p>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<h2>Web Hosting</h2>
|
||||
<p>You can easily find a web hosting company that offers the right mix of features and price for your applications.</p>
|
||||
<p><a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301867">Learn more »</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div style="float: left; border: 5px solid blue; margin: 5px; padding: 7px;">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.LabelForModel("ForModel")
|
||||
</td>
|
||||
<td>
|
||||
'@Html.DisplayNameForModel()'
|
||||
</td>
|
||||
<td>
|
||||
'@Html.NameForModel()'
|
||||
</td>
|
||||
<td>
|
||||
'@Html.ValueForModel()'
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.Label("Name")
|
||||
</td>
|
||||
<td>
|
||||
'@Html.DisplayName("Name")'
|
||||
</td>
|
||||
<td>
|
||||
'@Html.Name("Name")'
|
||||
</td>
|
||||
<td>
|
||||
'@Html.Value("Name")'
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.LabelFor(m => m.Address)
|
||||
</td>
|
||||
<td>
|
||||
'@Html.DisplayNameFor(m => m.Address)'
|
||||
</td>
|
||||
<td>
|
||||
'@Html.NameFor(m => m.Address)'
|
||||
</td>
|
||||
<td>
|
||||
'@Html.ValueFor(m => m.Address)'
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.Label("Anon.Address.Street")
|
||||
</td>
|
||||
<td>
|
||||
'@Html.DisplayName("Anon.Address.Street")'
|
||||
</td>
|
||||
<td>
|
||||
'@Html.Name("Anon.Address.Street")'
|
||||
</td>
|
||||
<td>
|
||||
'@Html.Value("Anon.Address.Street")'
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div style="float: left; border: 5px solid red; margin: 5px;">
|
||||
<p>Tags from View():</p>
|
||||
@await Component.InvokeAsync("Tags", 5, "View")
|
||||
<p>Tags from Content():</p>
|
||||
<p>@await Component.InvokeAsync("Tags", 5, "Content")</p>
|
||||
<p>Tags from Json():</p>
|
||||
<p>@await Component.InvokeAsync("Tags", 5, "Json")</p>
|
||||
<p style="padding: 0px 10px;">'@ViewBag.Title' should match page heading (still)</p>
|
||||
</div>
|
||||
<div style="float: left; border: thick solid lightskyblue; margin: 5px; padding: 7px;">
|
||||
@using (Html.BeginForm())
|
||||
{
|
||||
@Html.HiddenFor(m => m.Age)
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.Label("Name")
|
||||
</td>
|
||||
<td>
|
||||
@Html.TextBox("Name")
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.LabelFor(m => m.Address, htmlAttributes: new { @class="control-label col-md-2" })
|
||||
</td>
|
||||
<td>
|
||||
@Html.TextBoxFor(m => m.Address, htmlAttributes: new { @class = "form-control" })
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.Label("Alive")
|
||||
</td>
|
||||
<td>
|
||||
@Html.CheckBox("Alive")
|
||||
or
|
||||
@Html.RadioButton("Alive", value: false) False
|
||||
@Html.RadioButton("Alive", value: true) True
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.LabelFor(m => m.Dependent.Alive)
|
||||
</td>
|
||||
<td>
|
||||
@Html.CheckBoxFor(m => m.Dependent.Alive)
|
||||
or
|
||||
@Html.RadioButtonFor(m => m.Dependent.Alive, value: false) False
|
||||
@Html.RadioButtonFor(m => m.Dependent.Alive, value: true) True
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="submit" value="Save" class="btn btn-default" style="margin-left: 10px" />
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
}
|
||||
@{ Html.BeginForm(method: FormMethod.Post, htmlAttributes: new { someAttribute = "some value", }); }
|
||||
@Html.Hidden("Anon.Id")
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.Label("Anon.Name")
|
||||
</td>
|
||||
<td>
|
||||
@Html.TextBox("Anon.Name")
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.Label("Anon.Address.Street")
|
||||
</td>
|
||||
<td>
|
||||
@Html.TextBox("Anon.Address.Street", (object)ViewBag.Anon.Address.Street)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.Label("Anon.Address.City")
|
||||
</td>
|
||||
<td>
|
||||
@Html.TextBox("Anon.Address.City", value: null, format: "{0} (3)")
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.Label("Anon.Address.State")
|
||||
</td>
|
||||
<td>
|
||||
@Html.TextBox("Anon.Address.State", value: null, htmlAttributes: new { @class = "form-control" })
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.Label("Anon.Address.Country")
|
||||
</td>
|
||||
<td>
|
||||
@Html.TextBox("Anon.Address.Country", value: null, format: "{0} (4)",
|
||||
htmlAttributes: new { @class = "form-control" })
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<input type="submit" value="Save" class="btn btn-default" style="margin-left: 10px" />
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
@{ Html.EndForm(); }
|
||||
</div>
|
||||
<div style="float: left; border: 5px solid lightgreen; margin: 5px; padding: 7px;">
|
||||
@using (Html.BeginForm(controllerName: "Home", actionName: "Edit", method: FormMethod.Post))
|
||||
{
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.Label("Name", "Display / Edit Name")
|
||||
</td>
|
||||
<td>
|
||||
'@Html.Display("Name")'
|
||||
</td>
|
||||
<td>
|
||||
@Html.Editor("Name")
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.Label("Dependent.Name", "Display / Edit Dependent.Name")
|
||||
</td>
|
||||
<td>
|
||||
'@Html.Display("Dependent.Name")'
|
||||
</td>
|
||||
<td>
|
||||
@Html.Editor("Dependent.Name")
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.Label("Alive", "Display / Edit Alive")
|
||||
</td>
|
||||
<td>
|
||||
'@Html.Display("Alive")'
|
||||
</td>
|
||||
<td>
|
||||
@Html.Editor("Alive")
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.Label("Dependent.Alive", "Display / Edit Dependent.Alive")
|
||||
</td>
|
||||
<td>
|
||||
'@Html.Display("Dependent.Alive")'
|
||||
</td>
|
||||
<td>
|
||||
@Html.Editor("Dependent.Alive")
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.Label("Age", "Display / Edit Age")
|
||||
</td>
|
||||
<td>
|
||||
'@Html.Display("Age")'
|
||||
</td>
|
||||
<td>
|
||||
@Html.Editor("Age")
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.Label("GPA", "Display / Edit GPA")
|
||||
</td>
|
||||
<td>
|
||||
'@Html.Display("GPA")'
|
||||
</td>
|
||||
<td>
|
||||
@Html.Editor("GPA")
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
<div style="float: left; border: 5px dashed green; margin: 5px; padding: 7px;">
|
||||
@using (Html.BeginForm(controllerName: "Home", actionName: "Edit", method: FormMethod.Post))
|
||||
{
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.LabelFor(model => model.Name, "DisplayFor / EditFor Name")
|
||||
</td>
|
||||
<td>
|
||||
'@Html.DisplayFor(model => model.Name)'
|
||||
</td>
|
||||
<td>
|
||||
@Html.EditorFor(model => model.Name)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.LabelFor(model => model.Dependent.Name, "DisplayFor / EditFor Dependent.Name")
|
||||
</td>
|
||||
<td>
|
||||
'@Html.DisplayFor(model => model.Dependent.Name)'
|
||||
</td>
|
||||
<td>
|
||||
@Html.EditorFor(model => model.Dependent.Name)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.LabelFor(model => model.Alive, "DisplayFor / EditFor Alive")
|
||||
</td>
|
||||
<td>
|
||||
'@Html.DisplayFor(model => model.Alive)'
|
||||
</td>
|
||||
<td>
|
||||
@Html.EditorFor(model => model.Alive)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.LabelFor(model => model.Dependent.Alive, "DisplayFor / EditFor Dependent.Alive")
|
||||
</td>
|
||||
<td>
|
||||
'@Html.DisplayFor(model => model.Dependent.Alive)'
|
||||
</td>
|
||||
<td>
|
||||
@Html.EditorFor(model => model.Dependent.Alive)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.LabelFor(model => model.Age, "DisplayFor / EditFor Age")
|
||||
</td>
|
||||
<td>
|
||||
'@Html.DisplayFor(model => model.Age)'
|
||||
</td>
|
||||
<td>
|
||||
@Html.EditorFor(model => model.Age)
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
@Html.LabelFor(model => model.GPA, "DisplayFor / EditFor GPA")
|
||||
</td>
|
||||
<td>
|
||||
'@Html.DisplayFor(model => model.GPA)'
|
||||
</td>
|
||||
<td>
|
||||
@Html.EditorFor(model => model.GPA)
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div style="float: left; border: 5px solid darkseagreen; margin: 5px; padding: 7px;">
|
||||
@Html.DisplayForModel()
|
||||
</div>
|
||||
<div style="float: left; border: 5px dotted darkgreen; margin: 5px; padding: 7px">
|
||||
@Html.EditorForModel()
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>@ViewBag.Title - My ASP.NET Application</title>
|
||||
<link rel="stylesheet" href="~/content/bootstrap.min.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="/">Home</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container body-content">
|
||||
@await FlushAsync()
|
||||
@RenderBody()
|
||||
@RenderSection("content")
|
||||
<hr />
|
||||
<footer>
|
||||
<p>© @DateTime.Now.Year - My ASP.NET Application</p>
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>@ViewBag.Title - My ASP.NET Application</title>
|
||||
<link rel="stylesheet" href="~/content/bootstrap.min.css" />
|
||||
<style>
|
||||
body { padding-top: 60px; }
|
||||
@@media screen and (max-width: 768px) {
|
||||
body { padding-top: 0px; }
|
||||
}
|
||||
</style>
|
||||
@await RenderSectionAsync("header", required: false)
|
||||
</head>
|
||||
<body>
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="/">Home</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container body-content">
|
||||
@RenderBody()
|
||||
<hr />
|
||||
<footer>
|
||||
<p>© @DateTime.Now.Year - My ASP.NET Application</p>
|
||||
</footer>
|
||||
</div>
|
||||
@await RenderSectionAsync("footer", required: false)
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>@ViewBag.Title - Ma Requête ASP.NET</title>
|
||||
<link rel="stylesheet" href="~/content/bootstrap.min.css" />
|
||||
<style>
|
||||
body {
|
||||
padding-top: 60px;
|
||||
}
|
||||
|
||||
@@media screen and (max-width: 768px) {
|
||||
body {
|
||||
padding-top: 0px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@await RenderSectionAsync("header", required: false)
|
||||
</head>
|
||||
<body>
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a href="/">Accueil</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container body-content">
|
||||
@RenderBody()
|
||||
<hr />
|
||||
<footer>
|
||||
<p>© @DateTime.Now.Year - Mon Application ASP.NET</p>
|
||||
</footer>
|
||||
</div>
|
||||
@await RenderSectionAsync("footer", required: false)
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
{
|
||||
"name": "MvcSample.Web",
|
||||
"description": "Web site demonstrating various MVC features.",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"jquery": "1.11.2"
|
||||
},
|
||||
"exportsOverride": {
|
||||
"jquery": {
|
||||
"": "dist/jquery.{js,min.js,min.map}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
|
||||
module.exports = function (grunt) {
|
||||
grunt.initConfig({
|
||||
bower: {
|
||||
install: {
|
||||
options: {
|
||||
targetDir: "wwwroot/lib",
|
||||
layout: "byComponent",
|
||||
cleanTargetDir: false
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// This command registers the default task which will install bower packages into wwwroot/lib
|
||||
grunt.registerTask("default", ["bower:install"]);
|
||||
|
||||
// The following line loads the grunt plugins.
|
||||
// This line needs to be at the end of this this file.
|
||||
grunt.loadNpmTasks("grunt-bower-task");
|
||||
};
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"version": "0.0.0",
|
||||
"name": "MvcSample.Web",
|
||||
"private": true,
|
||||
"description": "Web site demonstrating various MVC features.",
|
||||
"devDependencies": {
|
||||
"grunt": "^0.4.5",
|
||||
"grunt-bower-task": "^0.4.0"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
MvcSample.Web
|
||||
===
|
||||
This sample web project illustrates various MVC 6 features. Please build from root
|
||||
(`.\build.cmd` on Windows; `./build.sh` elsewhere) before using this site.
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
.api-description {
|
||||
margin: 10px 0px 10px 0px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.api-description h5 {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.api-description hr {
|
||||
border: 0px;
|
||||
border-top: 1px solid #D44B4B;
|
||||
margin: 0px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.api-description table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.api-description thead {
|
||||
border-bottom: 1px solid black;
|
||||
}
|
||||
|
||||
.api-description td {
|
||||
border-bottom: 1px solid #CCCCCC;
|
||||
color: #666666;
|
||||
padding: 5px;
|
||||
}
|
||||
.api-description tr:last-child td {
|
||||
border-bottom: none;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
|
|
@ -1,65 +0,0 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
var MVC = (function () {
|
||||
"use strict";
|
||||
|
||||
// Takes the data which needs to be converted to form-url encoded format understadable by MVC.
|
||||
// This does not depend on jQuery. Can be used independently.
|
||||
var _stringify = function (data) {
|
||||
// This holds the stringified result.
|
||||
var result = "";
|
||||
|
||||
if (typeof data !== "object")
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
for (var element in data) {
|
||||
if (data.hasOwnProperty(element)) {
|
||||
result += process(element, data[element]);
|
||||
}
|
||||
}
|
||||
|
||||
// An '&' is appended at the end. Removing it.
|
||||
return result.substring(0, result.length - 1);
|
||||
};
|
||||
|
||||
function process(key, value, prefix) {
|
||||
// Ignore functions.
|
||||
if (typeof value === "function") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Object.prototype.toString.call(value) === "[object Array]") {
|
||||
var result = "";
|
||||
for (var i = 0; i < value.length; i++) {
|
||||
var tempPrefix = (prefix || key) + "[" + i + "]";
|
||||
result += process(key, value[i], tempPrefix);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
else if (typeof value === "object") {
|
||||
var result = "";
|
||||
for (var prop in value) {
|
||||
// This is to prevent looping through inherited proeprties.
|
||||
if (value.hasOwnProperty(prop)) {
|
||||
var tempPrefix = (prefix || key) + "." + prop;
|
||||
result += process(prop, value[prop], tempPrefix);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
else {
|
||||
return encodeURIComponent(prefix || key) + "=" + encodeURIComponent(value) + "&";
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
// Converts a Json object into MVC understandable format
|
||||
// when submitted as form-url-encoded data.
|
||||
stringify: _stringify
|
||||
};
|
||||
})()
|
||||
|
|
@ -1 +0,0 @@
|
|||
This is a sample file returned from a controller
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"directory": "wwwroot/lib"
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
# Ignore everything
|
||||
*
|
||||
|
|
@ -1,16 +1,15 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Mvc;
|
||||
|
||||
namespace MvcSample.Web.Areas.Travel.Controllers
|
||||
namespace MvcSandbox.Controllers
|
||||
{
|
||||
[Area("Travel")]
|
||||
public class HomeController : Controller
|
||||
{
|
||||
public IActionResult Index()
|
||||
{
|
||||
return Content("This is the Travel/Home/Index action.");
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,13 +6,18 @@
|
|||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>fbb2b86e-972b-4185-9ff2-62cab5f8388f</ProjectGuid>
|
||||
<ProjectGuid>14ed4476-9f24-4776-8417-ea6927f6c9c9</ProjectGuid>
|
||||
<RootNamespace>MvcSandbox</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<DevelopmentServerPort>40954</DevelopmentServerPort>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<DnxInvisibleContent Include="bower.json" />
|
||||
<DnxInvisibleContent Include=".bowerrc" />
|
||||
<DnxInvisibleContent Include="package.json" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MvcSandbox
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
// This method gets called by the runtime. Use this method to add services to the container.
|
||||
public IServiceProvider ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddMvc();
|
||||
|
||||
return services.BuildServiceProvider();
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
|
||||
{
|
||||
|
||||
app.UseStaticFiles();
|
||||
loggerFactory.AddConsole();
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
routes.MapRoute(
|
||||
name: "default",
|
||||
template: "{controller=Home}/{action=Index}/{id?}");
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
@{
|
||||
ViewData["Title"] = "Home Page";
|
||||
}
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<h2>Sandbox</h2>
|
||||
<ul>
|
||||
<li>This sandbox should give you a quick view of a basic MVC application.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>@ViewData["Title"] - MvcSandbox</title>
|
||||
|
||||
<environment names="Development">
|
||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
|
||||
<link rel="stylesheet" href="~/css/site.css" />
|
||||
</environment>
|
||||
<environment names="Staging,Production">
|
||||
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.5/css/bootstrap.min.css"
|
||||
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
|
||||
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
|
||||
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
|
||||
</environment>
|
||||
</head>
|
||||
<body>
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a asp-controller="Home" asp-action="Index" class="navbar-brand">MvcSandbox</a>
|
||||
</div>
|
||||
<div class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li><a asp-controller="Home" asp-action="Index">Home</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container body-content">
|
||||
@RenderBody()
|
||||
<hr />
|
||||
<footer>
|
||||
<p>© 2015 - MvcSandbox</p>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
<environment names="Development">
|
||||
<script src="~/lib/jquery/dist/jquery.js"></script>
|
||||
<script src="~/lib/bootstrap/dist/js/bootstrap.js"></script>
|
||||
<script src="~/js/site.js" asp-append-version="true"></script>
|
||||
</environment>
|
||||
<environment names="Staging,Production">
|
||||
<script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-2.1.4.min.js"
|
||||
asp-fallback-src="~/lib/jquery/dist/jquery.min.js"
|
||||
asp-fallback-test="window.jQuery">
|
||||
</script>
|
||||
<script src="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.5/bootstrap.min.js"
|
||||
asp-fallback-src="~/lib/bootstrap/dist/js/bootstrap.min.js"
|
||||
asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal">
|
||||
</script>
|
||||
<script src="~/js/site.min.js" asp-append-version="true"></script>
|
||||
</environment>
|
||||
|
||||
@RenderSection("scripts", required: false)
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
@using MvcSandbox
|
||||
@addTagHelper *, Microsoft.AspNet.Mvc.TagHelpers
|
||||
|
|
@ -1,3 +1,3 @@
|
|||
@{
|
||||
Layout = "_Layout";
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"name": "ASP.NET",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"bootstrap": "3.3.5",
|
||||
"jquery": "2.1.4",
|
||||
"jquery-validation": "1.14.0",
|
||||
"jquery-validation-unobtrusive": "3.2.4"
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/// <binding Clean='clean' />
|
||||
"use strict";
|
||||
|
||||
var gulp = require("gulp"),
|
||||
rimraf = require("rimraf"),
|
||||
concat = require("gulp-concat"),
|
||||
cssmin = require("gulp-cssmin"),
|
||||
uglify = require("gulp-uglify");
|
||||
|
||||
var paths = {
|
||||
webroot: "./wwwroot/"
|
||||
};
|
||||
|
||||
paths.js = paths.webroot + "js/**/*.js";
|
||||
paths.minJs = paths.webroot + "js/**/*.min.js";
|
||||
paths.css = paths.webroot + "css/**/*.css";
|
||||
paths.minCss = paths.webroot + "css/**/*.min.css";
|
||||
paths.concatJsDest = paths.webroot + "js/site.min.js";
|
||||
paths.concatCssDest = paths.webroot + "css/site.min.css";
|
||||
|
||||
gulp.task("clean:js", function (cb) {
|
||||
rimraf(paths.concatJsDest, cb);
|
||||
});
|
||||
|
||||
gulp.task("clean:css", function (cb) {
|
||||
rimraf(paths.concatCssDest, cb);
|
||||
});
|
||||
|
||||
gulp.task("clean", ["clean:js", "clean:css"]);
|
||||
|
||||
gulp.task("min:js", function () {
|
||||
return gulp.src([paths.js, "!" + paths.minJs], { base: "." })
|
||||
.pipe(concat(paths.concatJsDest))
|
||||
.pipe(uglify())
|
||||
.pipe(gulp.dest("."));
|
||||
});
|
||||
|
||||
gulp.task("min:css", function () {
|
||||
return gulp.src([paths.css, "!" + paths.minCss])
|
||||
.pipe(concat(paths.concatCssDest))
|
||||
.pipe(cssmin())
|
||||
.pipe(gulp.dest("."));
|
||||
});
|
||||
|
||||
gulp.task("min", ["min:js", "min:css"]);
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"name": "ASP.NET",
|
||||
"version": "0.0.0"
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
{
|
||||
"commands": {
|
||||
"web": "Microsoft.AspNet.Hosting server=Microsoft.AspNet.Server.WebListener server.urls=http://localhost:5001",
|
||||
"kestrel": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://localhost:5000"
|
||||
|
|
@ -7,15 +7,15 @@
|
|||
"warningsAsErrors": true
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
|
||||
"Microsoft.AspNet.Diagnostics": "1.0.0-*",
|
||||
"Microsoft.AspNet.Localization": "1.0.0-*",
|
||||
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-*",
|
||||
"Microsoft.AspNet.Mvc": "6.0.0-*",
|
||||
"Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-*",
|
||||
"Microsoft.AspNet.Mvc.WebApiCompatShim": "6.0.0-*",
|
||||
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-*",
|
||||
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
|
||||
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
|
||||
"Microsoft.AspNet.Session": "1.0.0-*",
|
||||
"Microsoft.AspNet.StaticFiles": "1.0.0-*",
|
||||
"Microsoft.AspNet.Tooling.Razor": "1.0.0-*",
|
||||
"Microsoft.Extensions.CodeGenerators.Mvc": "1.0.0-*",
|
||||
"Microsoft.Extensions.Configuration.Json": "1.0.0-*",
|
||||
"Microsoft.Extensions.Logging.Console": "1.0.0-*"
|
||||
},
|
||||
|
|
@ -23,6 +23,7 @@
|
|||
"dnx451": { },
|
||||
"dnxcore50": { }
|
||||
},
|
||||
|
||||
"exclude": [
|
||||
"wwwroot",
|
||||
"node_modules",
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
/// <autosync enabled="true" />
|
||||
/// <reference path="../gulpfile.js" />
|
||||
/// <reference path="js/site.js" />
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
body {
|
||||
padding-top: 50px;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
/* Wrapping element */
|
||||
/* Set some basic padding to keep content from hitting the edges */
|
||||
.body-content {
|
||||
padding-left: 15px;
|
||||
padding-right: 15px;
|
||||
}
|
||||
|
||||
/* Set widths on the form inputs since otherwise they're 100% wide */
|
||||
input,
|
||||
select,
|
||||
textarea {
|
||||
max-width: 280px;
|
||||
}
|
||||
|
||||
/* Carousel */
|
||||
.carousel-caption {
|
||||
z-index: 10 !important;
|
||||
}
|
||||
|
||||
.carousel-caption p {
|
||||
font-size: 20px;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) {
|
||||
.carousel-caption {
|
||||
z-index: 10 !important;
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
|
|
@ -0,0 +1 @@
|
|||
// Write your Javascript code.
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<system.webServer>
|
||||
<handlers>
|
||||
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
|
||||
</handlers>
|
||||
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" startupTimeLimit="3600"/>
|
||||
</system.webServer>
|
||||
</configuration>
|
||||
|
|
@ -1,147 +0,0 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Mvc.Formatters.Xml;
|
||||
using Microsoft.AspNet.Testing.xunit;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class MvcSampleTests : IClassFixture<MvcTestFixture<MvcSample.Web.Startup>>
|
||||
{
|
||||
public MvcSampleTests(MvcTestFixture<MvcSample.Web.Startup> fixture)
|
||||
{
|
||||
Client = fixture.Client;
|
||||
}
|
||||
|
||||
public HttpClient Client { get; }
|
||||
|
||||
[Theory]
|
||||
[InlineData("")] // Shared/MyView.cshtml
|
||||
[InlineData("/")] // Shared/MyView.cshtml
|
||||
[InlineData("/Home/Index")] // Shared/MyView.cshtml
|
||||
[InlineData("/Home/Create")] // Home/Create.cshtml
|
||||
[InlineData("/Home/FlushPoint")] // Home/FlushPoint.cshtml
|
||||
[InlineData("/Home/InjectSample")] // Home/InjectSample.cshtml
|
||||
[InlineData("/Home/Language")] // Home/Language.cshtml
|
||||
[InlineData("/Home/MyView")] // Shared/MyView.cshtml
|
||||
[InlineData("/Home/NullUser")] // Home/NullUser.cshtml
|
||||
[InlineData("/Home/Post")] // Shared/MyView.cshtml with null User
|
||||
[InlineData("/Home/SaveUser")] // Shared/MyView.cshtml with uninitialized User instance
|
||||
[InlineData("/Home/ValidationSummary")] // Home/ValidationSummary.cshtml
|
||||
public async Task Home_Pages_ReturnSuccess(string path)
|
||||
{
|
||||
// Arrange & Act
|
||||
var response = await Client.GetAsync("http://localhost" + path);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("Name=SamplePerson&Address.Street=SampleStreet&Address.City=SampleCity&" +
|
||||
"Address.State=SampleState&Address.ZipCode=11&PastJobs[0].JobTitle=SampleJob1&" +
|
||||
"PastJobs[0].EmployerName=Employer1&PastJobs[0].Years=2&PastJobs[1].JobTitle=SampleJob2&" +
|
||||
"PastJobs[1].EmployerName=Employer2&PastJobs[1].Years=4&PastJobs[2].JobTitle=SampleJob3&" +
|
||||
"PastJobs[2].EmployerName=Employer3&PastJobs[2].Years=1", "true")]
|
||||
// Input with some special characters
|
||||
[InlineData("Name=SamplePerson&Address.Street=SampleStre'et&Address.City=S\ampleCity&" +
|
||||
"Address.State=SampleState&Address.ZipCode=11&PastJobs[0].JobTitle=S~ampleJob1&" +
|
||||
"PastJobs[0].EmployerName=Employer1&PastJobs[0].Years=2&PastJobs[1].JobTitle=SampleJob2&" +
|
||||
"PastJobs[1].EmployerName=Employer2&PastJobs[1].Years=4&PastJobs[2].JobTitle=SampleJob3&" +
|
||||
"PastJobs[2].EmployerName=Employer3&PastJobs[2].Years=1", "true")]
|
||||
[InlineData("Name=SamplePerson", "false")]
|
||||
public async Task FormUrlEncoded_ReturnsAppropriateResults(string input, string expectedOutput)
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(HttpMethod.Post, "http://localhost/FormUrlEncoded/IsValidPerson");
|
||||
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
|
||||
request.Content = new StringContent(input, Encoding.UTF8, "application/x-www-form-urlencoded");
|
||||
|
||||
// Act
|
||||
var response = await Client.SendAsync(request);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(expectedOutput, await response.Content.ReadAsStringAsync());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task FormUrlEncoded_Index_ReturnSuccess()
|
||||
{
|
||||
// Arrange & Act
|
||||
var response = await Client.GetAsync("http://localhost/FormUrlEncoded");
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Home_NotFoundAction_Returns404()
|
||||
{
|
||||
// Arrange & Act
|
||||
var response = await Client.GetAsync("http://localhost/Home/NotFound");
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||
}
|
||||
|
||||
[ConditionalFact]
|
||||
// Mono.Xml2.XmlTextReader.ReadText is unable to read the XML. This is fixed in mono 4.3.0.
|
||||
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
|
||||
public async Task Home_CreateUser_ReturnsXmlBasedOnAcceptHeader()
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Home/ReturnUser");
|
||||
request.Headers.Accept.Add(MediaTypeWithQualityHeaderValue.Parse("application/xml"));
|
||||
|
||||
// Act
|
||||
var response = await Client.SendAsync(request);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
XmlAssert.Equal("<User xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=" +
|
||||
"\"http://schemas.datacontract.org/2004/07/MvcSample.Web.Models\"><About>I like playing Football" +
|
||||
"</About><Address>My address</Address><Age>13</Age><Alive>true</Alive><Dependent><About i:nil=\"true\" />" +
|
||||
"<Address>Dependents address</Address><Age>0</Age><Alive>false</Alive><Dependent i:nil=\"true\" />" +
|
||||
"<EnumInformation>Zero</EnumInformation><GPA>0</GPA><Log i:nil=\"true\" /><Name>Dependents name</Name>" +
|
||||
"<Profession i:nil=\"true\" /></Dependent><EnumInformation>Zero</EnumInformation><GPA>13.37</GPA><Log i:nil=\"true\" />" +
|
||||
"<Name>My name</Name><Profession>Software Engineer</Profession></User>",
|
||||
await response.Content.ReadAsStringAsync());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("http://localhost/Filters/ChallengeUser", HttpStatusCode.Unauthorized)]
|
||||
[InlineData("http://localhost/Filters/AllGranted", HttpStatusCode.Unauthorized)]
|
||||
[InlineData("http://localhost/Filters/NotGrantedClaim", HttpStatusCode.Unauthorized)]
|
||||
public async Task FiltersController_Tests(string url, HttpStatusCode statusCode)
|
||||
{
|
||||
// Arrange & Act
|
||||
var response = await Client.GetAsync(url);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Equal(statusCode, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task FiltersController_Crash_ThrowsException()
|
||||
{
|
||||
// Arrange & Act
|
||||
var response = await Client.GetAsync("http://localhost/Filters/Crash?message=HelloWorld");
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.Equal("Boom HelloWorld", await response.Content.ReadAsStringAsync());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class MvcSandboxTest : IClassFixture<MvcTestFixture<MvcSandbox.Startup>>
|
||||
{
|
||||
public MvcSandboxTest(MvcTestFixture<MvcSandbox.Startup> fixture)
|
||||
{
|
||||
Client = fixture.Client;
|
||||
}
|
||||
|
||||
public HttpClient Client { get; }
|
||||
|
||||
[Theory]
|
||||
[InlineData("")] // Shared/MyView.cshtml
|
||||
[InlineData("/")] // Shared/MyView.cshtml
|
||||
[InlineData("/Home/Index")] // Shared/MyView.cshtml
|
||||
public async Task Home_Pages_ReturnSuccess(string path)
|
||||
{
|
||||
// Arrange & Act
|
||||
var response = await Client.GetAsync("http://localhost" + path);
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Home_NotFoundAction_Returns404()
|
||||
{
|
||||
// Arrange & Act
|
||||
var response = await Client.GetAsync("http://localhost/Home/NotFound");
|
||||
|
||||
// Assert
|
||||
Assert.NotNull(response);
|
||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@
|
|||
"Microsoft.Extensions.Configuration.Json": "1.0.0-*",
|
||||
"Microsoft.Extensions.Logging.Testing": "1.0.0-*",
|
||||
"ModelBindingWebSite": "1.0.0",
|
||||
"MvcSample.Web": "1.0.0",
|
||||
"MvcSandbox": "1.0.0",
|
||||
"PrecompilationWebSite": "1.0.0",
|
||||
"RazorEmbeddedViewsWebSite": "1.0.0",
|
||||
"RazorPageExecutionInstrumentationWebSite": "1.0.0",
|
||||
|
|
|
|||
Loading…
Reference in New Issue