diff --git a/Mvc.NoFun.sln b/Mvc.NoFun.sln index b23f7460b1..0f306eb7d7 100644 --- a/Mvc.NoFun.sln +++ b/Mvc.NoFun.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.22130.0 +VisualStudioVersion = 14.0.22013.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{DAAE4C74-D06F-4874-A166-33305D2643CE}" EndProject @@ -42,6 +42,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution global.json = global.json EndProjectSection EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.WebApiCompatShim", "src\Microsoft.AspNet.Mvc.WebApiCompatShim\Microsoft.AspNet.Mvc.WebApiCompatShim.kproj", "{23D30B8C-04B1-4577-A604-ED27EA1E4A0E}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.WebApiCompatShimTest", "test\Microsoft.AspNet.Mvc.WebApiCompatShimTest\Microsoft.AspNet.Mvc.WebApiCompatShimTest.kproj", "{5DE8E4D9-AACD-4B5F-819F-F091383FB996}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -192,6 +196,26 @@ Global {E69FD235-2042-43A4-9970-59CB29955B4E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {E69FD235-2042-43A4-9970-59CB29955B4E}.Release|Mixed Platforms.Build.0 = Release|Any CPU {E69FD235-2042-43A4-9970-59CB29955B4E}.Release|x86.ActiveCfg = Release|Any CPU + {23D30B8C-04B1-4577-A604-ED27EA1E4A0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {23D30B8C-04B1-4577-A604-ED27EA1E4A0E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {23D30B8C-04B1-4577-A604-ED27EA1E4A0E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {23D30B8C-04B1-4577-A604-ED27EA1E4A0E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {23D30B8C-04B1-4577-A604-ED27EA1E4A0E}.Debug|x86.ActiveCfg = Debug|Any CPU + {23D30B8C-04B1-4577-A604-ED27EA1E4A0E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {23D30B8C-04B1-4577-A604-ED27EA1E4A0E}.Release|Any CPU.Build.0 = Release|Any CPU + {23D30B8C-04B1-4577-A604-ED27EA1E4A0E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {23D30B8C-04B1-4577-A604-ED27EA1E4A0E}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {23D30B8C-04B1-4577-A604-ED27EA1E4A0E}.Release|x86.ActiveCfg = Release|Any CPU + {5DE8E4D9-AACD-4B5F-819F-F091383FB996}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5DE8E4D9-AACD-4B5F-819F-F091383FB996}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5DE8E4D9-AACD-4B5F-819F-F091383FB996}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {5DE8E4D9-AACD-4B5F-819F-F091383FB996}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {5DE8E4D9-AACD-4B5F-819F-F091383FB996}.Debug|x86.ActiveCfg = Debug|Any CPU + {5DE8E4D9-AACD-4B5F-819F-F091383FB996}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5DE8E4D9-AACD-4B5F-819F-F091383FB996}.Release|Any CPU.Build.0 = Release|Any CPU + {5DE8E4D9-AACD-4B5F-819F-F091383FB996}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {5DE8E4D9-AACD-4B5F-819F-F091383FB996}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {5DE8E4D9-AACD-4B5F-819F-F091383FB996}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -211,5 +235,7 @@ Global {5F945B82-FE5F-425C-956C-8BC2F2020254} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} {98335B23-E4B9-4CAD-9749-0DED32A659A1} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} {E69FD235-2042-43A4-9970-59CB29955B4E} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} + {23D30B8C-04B1-4577-A604-ED27EA1E4A0E} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} + {5DE8E4D9-AACD-4B5F-819F-F091383FB996} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} EndGlobalSection EndGlobal diff --git a/Mvc.sln b/Mvc.sln index b47670f815..9bd980f531 100644 --- a/Mvc.sln +++ b/Mvc.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.22013.1 +VisualStudioVersion = 14.0.22209.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{DAAE4C74-D06F-4874-A166-33305D2643CE}" EndProject @@ -92,6 +92,18 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "RazorInstrumentationWebSite EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ApplicationModelWebSite", "test\WebSites\ApplicationModelWebSite\ApplicationModelWebSite.kproj", "{CAE52CB7-0FAC-4B5B-8251-B0FF837DB657}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.WebApiCompatShim", "src\Microsoft.AspNet.Mvc.WebApiCompatShim\Microsoft.AspNet.Mvc.WebApiCompatShim.kproj", "{23D30B8C-04B1-4577-A604-ED27EA1E4A0E}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "WebApiCompatShimWebSite", "test\WebSites\WebApiCompatShimWebSite\WebApiCompatShimWebSite.kproj", "{B2B7BC91-688E-4C1E-A71F-CE948D958DDF}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.WebApiCompatShimTest", "test\Microsoft.AspNet.Mvc.WebApiCompatShimTest\Microsoft.AspNet.Mvc.WebApiCompatShimTest.kproj", "{5DE8E4D9-AACD-4B5F-819F-F091383FB996}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "TagHelperSample.Web", "samples\TagHelperSample.Web\TagHelperSample.Web.kproj", "{2223120F-D675-40DA-8CD8-11DC14A0B2C7}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.TagHelpers", "src\Microsoft.AspNet.Mvc.TagHelpers\Microsoft.AspNet.Mvc.TagHelpers.kproj", "{B2347320-308E-4D2B-AEC8-005DFA68B0C9}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Mvc.TagHelpers.Test", "test\Microsoft.AspNet.Mvc.TagHelpers.Test\Microsoft.AspNet.Mvc.TagHelpers.Test.kproj", "{860119ED-3DB1-424D-8D0A-30132A8A7D96}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -482,6 +494,66 @@ Global {CAE52CB7-0FAC-4B5B-8251-B0FF837DB657}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {CAE52CB7-0FAC-4B5B-8251-B0FF837DB657}.Release|Mixed Platforms.Build.0 = Release|Any CPU {CAE52CB7-0FAC-4B5B-8251-B0FF837DB657}.Release|x86.ActiveCfg = Release|Any CPU + {23D30B8C-04B1-4577-A604-ED27EA1E4A0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {23D30B8C-04B1-4577-A604-ED27EA1E4A0E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {23D30B8C-04B1-4577-A604-ED27EA1E4A0E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {23D30B8C-04B1-4577-A604-ED27EA1E4A0E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {23D30B8C-04B1-4577-A604-ED27EA1E4A0E}.Debug|x86.ActiveCfg = Debug|Any CPU + {23D30B8C-04B1-4577-A604-ED27EA1E4A0E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {23D30B8C-04B1-4577-A604-ED27EA1E4A0E}.Release|Any CPU.Build.0 = Release|Any CPU + {23D30B8C-04B1-4577-A604-ED27EA1E4A0E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {23D30B8C-04B1-4577-A604-ED27EA1E4A0E}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {23D30B8C-04B1-4577-A604-ED27EA1E4A0E}.Release|x86.ActiveCfg = Release|Any CPU + {B2B7BC91-688E-4C1E-A71F-CE948D958DDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B2B7BC91-688E-4C1E-A71F-CE948D958DDF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B2B7BC91-688E-4C1E-A71F-CE948D958DDF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {B2B7BC91-688E-4C1E-A71F-CE948D958DDF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {B2B7BC91-688E-4C1E-A71F-CE948D958DDF}.Debug|x86.ActiveCfg = Debug|Any CPU + {B2B7BC91-688E-4C1E-A71F-CE948D958DDF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B2B7BC91-688E-4C1E-A71F-CE948D958DDF}.Release|Any CPU.Build.0 = Release|Any CPU + {B2B7BC91-688E-4C1E-A71F-CE948D958DDF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {B2B7BC91-688E-4C1E-A71F-CE948D958DDF}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {B2B7BC91-688E-4C1E-A71F-CE948D958DDF}.Release|x86.ActiveCfg = Release|Any CPU + {5DE8E4D9-AACD-4B5F-819F-F091383FB996}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {5DE8E4D9-AACD-4B5F-819F-F091383FB996}.Debug|Any CPU.Build.0 = Debug|Any CPU + {5DE8E4D9-AACD-4B5F-819F-F091383FB996}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {5DE8E4D9-AACD-4B5F-819F-F091383FB996}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {5DE8E4D9-AACD-4B5F-819F-F091383FB996}.Debug|x86.ActiveCfg = Debug|Any CPU + {5DE8E4D9-AACD-4B5F-819F-F091383FB996}.Release|Any CPU.ActiveCfg = Release|Any CPU + {5DE8E4D9-AACD-4B5F-819F-F091383FB996}.Release|Any CPU.Build.0 = Release|Any CPU + {5DE8E4D9-AACD-4B5F-819F-F091383FB996}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {5DE8E4D9-AACD-4B5F-819F-F091383FB996}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {5DE8E4D9-AACD-4B5F-819F-F091383FB996}.Release|x86.ActiveCfg = Release|Any CPU + {2223120F-D675-40DA-8CD8-11DC14A0B2C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2223120F-D675-40DA-8CD8-11DC14A0B2C7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2223120F-D675-40DA-8CD8-11DC14A0B2C7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {2223120F-D675-40DA-8CD8-11DC14A0B2C7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {2223120F-D675-40DA-8CD8-11DC14A0B2C7}.Debug|x86.ActiveCfg = Debug|Any CPU + {2223120F-D675-40DA-8CD8-11DC14A0B2C7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2223120F-D675-40DA-8CD8-11DC14A0B2C7}.Release|Any CPU.Build.0 = Release|Any CPU + {2223120F-D675-40DA-8CD8-11DC14A0B2C7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {2223120F-D675-40DA-8CD8-11DC14A0B2C7}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {2223120F-D675-40DA-8CD8-11DC14A0B2C7}.Release|x86.ActiveCfg = Release|Any CPU + {B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Debug|x86.ActiveCfg = Debug|Any CPU + {B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Release|Any CPU.Build.0 = Release|Any CPU + {B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {B2347320-308E-4D2B-AEC8-005DFA68B0C9}.Release|x86.ActiveCfg = Release|Any CPU + {860119ED-3DB1-424D-8D0A-30132A8A7D96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {860119ED-3DB1-424D-8D0A-30132A8A7D96}.Debug|Any CPU.Build.0 = Debug|Any CPU + {860119ED-3DB1-424D-8D0A-30132A8A7D96}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {860119ED-3DB1-424D-8D0A-30132A8A7D96}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {860119ED-3DB1-424D-8D0A-30132A8A7D96}.Debug|x86.ActiveCfg = Debug|Any CPU + {860119ED-3DB1-424D-8D0A-30132A8A7D96}.Release|Any CPU.ActiveCfg = Release|Any CPU + {860119ED-3DB1-424D-8D0A-30132A8A7D96}.Release|Any CPU.Build.0 = Release|Any CPU + {860119ED-3DB1-424D-8D0A-30132A8A7D96}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {860119ED-3DB1-424D-8D0A-30132A8A7D96}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {860119ED-3DB1-424D-8D0A-30132A8A7D96}.Release|x86.ActiveCfg = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -526,5 +598,11 @@ Global {0EF9860B-10D7-452F-B0F4-A405B88BEBB3} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} {2B2B9876-903C-4065-8D62-2EE832BBA106} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} {CAE52CB7-0FAC-4B5B-8251-B0FF837DB657} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} + {23D30B8C-04B1-4577-A604-ED27EA1E4A0E} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} + {B2B7BC91-688E-4C1E-A71F-CE948D958DDF} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C} + {5DE8E4D9-AACD-4B5F-819F-F091383FB996} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} + {2223120F-D675-40DA-8CD8-11DC14A0B2C7} = {DAAE4C74-D06F-4874-A166-33305D2643CE} + {B2347320-308E-4D2B-AEC8-005DFA68B0C9} = {32285FA4-6B46-4D6B-A840-2B13E4C8B58E} + {860119ED-3DB1-424D-8D0A-30132A8A7D96} = {3BA657BF-28B1-42DA-B5B0-1C4601FCF7B1} EndGlobalSection EndGlobal diff --git a/samples/MvcSample.Web/Controllers/ApiExplorerSamples/ProductsController.cs b/samples/MvcSample.Web/Controllers/ApiExplorerSamples/ProductsController.cs index fd64e2b472..538791b98d 100644 --- a/samples/MvcSample.Web/Controllers/ApiExplorerSamples/ProductsController.cs +++ b/samples/MvcSample.Web/Controllers/ApiExplorerSamples/ProductsController.cs @@ -9,7 +9,7 @@ namespace MvcSample.Web.ApiExplorerSamples [Route("api/Products")] public class ProductsController : Controller { - [HttpGet("{id}")] + [HttpGet("{id:int}")] public Product GetById(int id) { return null; @@ -22,7 +22,7 @@ public IEnumerable SearchByName(string name) } [Produces("application/json", Type = typeof(ProductOrderConfirmation))] - [HttpPut("{id}/Buy")] + [HttpPut("{id:int}/Buy")] public IActionResult Buy(int projectId, int quantity = 1) { return null; diff --git a/samples/MvcSample.Web/Startup.cs b/samples/MvcSample.Web/Startup.cs index 9e40c3b1ed..21bc2a2d35 100644 --- a/samples/MvcSample.Web/Startup.cs +++ b/samples/MvcSample.Web/Startup.cs @@ -41,7 +41,7 @@ public void Configure(IApplicationBuilder app) // Setup services with a test AssemblyProvider so that only the // sample's assemblies are loaded. This prevents loading controllers from other assemblies // when the sample is used in the Functional Tests. - services.AddTransient>(); + services.AddTransient>(); services.ConfigureOptions(options => { options.Filters.Add(typeof(PassThroughAttribute), order: 17); @@ -81,7 +81,7 @@ public void Configure(IApplicationBuilder app) // Setup services with a test AssemblyProvider so that only the // sample's assemblies are loaded. This prevents loading controllers from other assemblies // when the sample is used in the Functional Tests. - services.AddTransient>(); + services.AddTransient>(); services.ConfigureOptions(options => { diff --git a/samples/MvcSample.Web/TestAssemblyProvider.cs b/samples/MvcSample.Web/TestAssemblyProvider.cs index b1db4925f5..98b5fd9f7c 100644 --- a/samples/MvcSample.Web/TestAssemblyProvider.cs +++ b/samples/MvcSample.Web/TestAssemblyProvider.cs @@ -17,7 +17,7 @@ namespace MvcSample.Web /// This is a generic type because it needs to instantiated by a service provider to replace /// a built-in MVC service. /// - public class TestAssemblyProvider : IControllerAssemblyProvider + public class TestAssemblyProvider : IAssemblyProvider { public TestAssemblyProvider() { diff --git a/samples/MvcSample.Web/Views/ApiExplorer/_ApiDescription.cshtml b/samples/MvcSample.Web/Views/ApiExplorer/_ApiDescription.cshtml index b0e24064b4..f3e73a79b2 100644 --- a/samples/MvcSample.Web/Views/ApiExplorer/_ApiDescription.cshtml +++ b/samples/MvcSample.Web/Views/ApiExplorer/_ApiDescription.cshtml @@ -13,7 +13,11 @@
    @foreach (var parameter in Model.ParameterDescriptions) { -
  • @parameter.Name - @parameter.Type.FullName - @parameter.Source.ToString()
  • +
  • + @parameter.Name - @(parameter?.Type?.FullName ?? "Unknown") - @parameter.Source.ToString() + - Constraint: @(parameter?.Constraint?.GetType()?.Name?.Replace("RouteConstraint", "") ?? " none") + - Default value: @(parameter?.DefaultValue ?? " none") +
  • }
} @@ -22,7 +26,7 @@ {

Response Formats:

    - @foreach(var response in Model.SupportedResponseFormats) + @foreach (var response in Model.SupportedResponseFormats) {
  • @response.MediaType.RawValue - @response.Formatter.GetType().Name
  • } diff --git a/samples/MvcSample.Web/Views/Home/FlushPoint.cshtml b/samples/MvcSample.Web/Views/Home/FlushPoint.cshtml index 1f79342528..4e95f0aabf 100644 --- a/samples/MvcSample.Web/Views/Home/FlushPoint.cshtml +++ b/samples/MvcSample.Web/Views/Home/FlushPoint.cshtml @@ -45,10 +45,9 @@ Marketing: Marketing@example.com -@* Remove the Wait() calls once we add support for async sections *@ @{ - FlushAsync().Wait(); - Task.Delay(TimeSpan.FromSeconds(1)).Wait(); + await FlushAsync(); + await Task.Delay(TimeSpan.FromSeconds(1)); }
    diff --git a/samples/MvcSample.Web/Views/Shared/_Layout.cshtml b/samples/MvcSample.Web/Views/Shared/_Layout.cshtml index 767b0b972e..2e843399cb 100644 --- a/samples/MvcSample.Web/Views/Shared/_Layout.cshtml +++ b/samples/MvcSample.Web/Views/Shared/_Layout.cshtml @@ -11,7 +11,7 @@ body { padding-top: 0px; } } - @RenderSection("header", required: false) + @await RenderSectionAsync("header", required: false) - @RenderSection("footer", required: false) + @await RenderSectionAsync("footer", required: false) diff --git a/samples/TagHelperSample.Web/Controllers/HomeController.cs b/samples/TagHelperSample.Web/Controllers/HomeController.cs new file mode 100644 index 0000000000..1a9188cdf9 --- /dev/null +++ b/samples/TagHelperSample.Web/Controllers/HomeController.cs @@ -0,0 +1,75 @@ + +using System.Collections.Generic; +using System.Linq; +using Microsoft.AspNet.Mvc; +using Microsoft.AspNet.Mvc.Rendering; +using TagHelperSample.Web.Models; + +namespace TagHelperSample.Web.Controllers +{ + public class HomeController : Controller + { + private static readonly IEnumerable _items = new SelectList(Enumerable.Range(7, 13)); + private static readonly Dictionary _users = new Dictionary(); + private static int _next; + + public HomeController() + { + // Unable to set ViewBag from constructor. Does this work in MVC 5.2? + ////ViewBag.Items = _items; + } + + // GET: // + public IActionResult Index() + { + return View(_users.Values); + } + + // GET: /Home/Create + public IActionResult Create() + { + ViewBag.Items = _items; + return View(); + } + + // POST: Home/Create + [HttpPost] + public IActionResult Create(User user) + { + if (user != null && ModelState.IsValid) + { + var id = _next++; + user.Id = id; + _users[id] = user; + return RedirectToAction("Index"); + } + + ViewBag.Items = _items; + return View(); + } + + // GET: /Home/Edit/5 + public IActionResult Edit(int id) + { + User user; + _users.TryGetValue(id, out user); + + ViewBag.Items = _items; + return View(user); + } + + // POST: Home/Edit/5 + [HttpPost] + public IActionResult Edit(int id, User user) + { + if (user != null && id == user.Id && _users.ContainsKey(id) && ModelState.IsValid) + { + _users[id] = user; + return RedirectToAction("Index"); + } + + ViewBag.Items = _items; + return View(); + } + } +} diff --git a/samples/TagHelperSample.Web/Models/User.cs b/samples/TagHelperSample.Web/Models/User.cs new file mode 100644 index 0000000000..eb1b574a67 --- /dev/null +++ b/samples/TagHelperSample.Web/Models/User.cs @@ -0,0 +1,18 @@ + +using System; + +namespace TagHelperSample.Web.Models +{ + public class User + { + public int Id { get; set; } + + public string Name { get; set; } + + public string Blurb { get; set; } + + public DateTimeOffset DateOfBirth { get; set; } + + public int YearsEmployeed { get; set; } + } +} \ No newline at end of file diff --git a/samples/TagHelperSample.Web/Startup.cs b/samples/TagHelperSample.Web/Startup.cs new file mode 100644 index 0000000000..d086501aea --- /dev/null +++ b/samples/TagHelperSample.Web/Startup.cs @@ -0,0 +1,15 @@ + +using Microsoft.AspNet.Builder; +using Microsoft.Framework.DependencyInjection; + +namespace TagHelperSample.Web +{ + public class Startup + { + public void Configure(IApplicationBuilder app) + { + app.UsePerRequestServices(services => services.AddMvc()); + app.UseMvc(); + } + } +} diff --git a/samples/TagHelperSample.Web/TagHelperSample.Web.kproj b/samples/TagHelperSample.Web/TagHelperSample.Web.kproj new file mode 100644 index 0000000000..3d932a6a8f --- /dev/null +++ b/samples/TagHelperSample.Web/TagHelperSample.Web.kproj @@ -0,0 +1,18 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 2223120f-d675-40da-8cd8-11dc14a0b2c7 + Web + TagHelperSample.Web + + + 2.0 + 31726 + + + \ No newline at end of file diff --git a/samples/TagHelperSample.Web/Views/Home/Create.cshtml b/samples/TagHelperSample.Web/Views/Home/Create.cshtml new file mode 100644 index 0000000000..5dd527a160 --- /dev/null +++ b/samples/TagHelperSample.Web/Views/Home/Create.cshtml @@ -0,0 +1,90 @@ + +@using TagHelperSample.Web.Models +@model User +@addtaghelper "Microsoft.AspNet.Mvc.TagHelpers" + +

    Create

    + +@* anti-forgery is on by default *@ +@* form will special-case anything that looks like a URI i.e. contains a '/' or doesn't match an action *@ +
    +
    + @* validation summary tag helper will target just
    elements and append the list of errors *@ + @* - i.e. this helper, like + +
    + @* no special-case for the "for" attribute; may eventually need to opt out on per-element basis here and in *@ +
    +
    +
    +
    +
    + + + diff --git a/samples/TagHelperSample.Web/Views/Home/Edit.cshtml b/samples/TagHelperSample.Web/Views/Home/Edit.cshtml new file mode 100644 index 0000000000..777b55fcd5 --- /dev/null +++ b/samples/TagHelperSample.Web/Views/Home/Edit.cshtml @@ -0,0 +1,62 @@ + +@using TagHelperSample.Web.Models +@model User +@addtaghelper "Microsoft.AspNet.Mvc.TagHelpers" + +

    Edit

    + +
    +
    +
    + + +
    +
    +
    +
    +
    +
    +
    +
    + +
    +
    + +
    +
    +
    + + + diff --git a/samples/TagHelperSample.Web/Views/Home/Index.cshtml b/samples/TagHelperSample.Web/Views/Home/Index.cshtml new file mode 100644 index 0000000000..443d79ad37 --- /dev/null +++ b/samples/TagHelperSample.Web/Views/Home/Index.cshtml @@ -0,0 +1,38 @@ + +@using TagHelperSample.Web.Models +@model IEnumerable +@addtaghelper "Microsoft.AspNet.Mvc.TagHelpers" + +

    Index

    +

    + Create New +

    + +@if (Model != null && Model.Count() != 0) +{ +
    + @for (var index = 0; index < Model.Count(); ++index) + { + @* +
    +
    +
    +
    +
    +
    +
    +