Remove more `TestHelper` functional tests
- remove tests already thoroughly covered in unit tests - #3139 part 2 of 3 - make checks of `<form>` tag helper more consistent with others - use a tag helper initializer but testing every variant; covered in unit tests - remove `MvcStartupTest` and associated web site - scenario covered elsewhere - remove `PrecompilationTest.PrecompiledView_RendersCorrectly()` - scenario covered elsewhere and shouldn't do I/O on checked-in files
This commit is contained in:
parent
ff19702db5
commit
c8c0c5303e
13
Mvc.sln
13
Mvc.sln
|
|
@ -54,8 +54,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "ContentNegotiationWebSite", "test\WebSites\ContentNegotiationWebSite\ContentNegotiationWebSite.xproj", "{C6E5AFFA-890A-448F-8DE3-878B1D3C9FC7}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "AddServicesWebSite", "test\WebSites\AddServicesWebSite\AddServicesWebSite.xproj", "{6A0B65CE-6B01-40D0-840D-EFF3680D1547}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "FiltersWebSite", "test\WebSites\FiltersWebSite\FiltersWebSite.xproj", "{1976AC4A-FEA4-4587-A158-D9F79736D2B6}"
|
||||
EndProject
|
||||
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "UrlHelperWebSite", "test\WebSites\UrlHelperWebSite\UrlHelperWebSite.xproj", "{A192E504-2881-41DC-90D1-B7F1DD1134E8}"
|
||||
|
|
@ -382,16 +380,6 @@ Global
|
|||
{C6E5AFFA-890A-448F-8DE3-878B1D3C9FC7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{C6E5AFFA-890A-448F-8DE3-878B1D3C9FC7}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{C6E5AFFA-890A-448F-8DE3-878B1D3C9FC7}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{6A0B65CE-6B01-40D0-840D-EFF3680D1547}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6A0B65CE-6B01-40D0-840D-EFF3680D1547}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6A0B65CE-6B01-40D0-840D-EFF3680D1547}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
{6A0B65CE-6B01-40D0-840D-EFF3680D1547}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
|
||||
{6A0B65CE-6B01-40D0-840D-EFF3680D1547}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{6A0B65CE-6B01-40D0-840D-EFF3680D1547}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6A0B65CE-6B01-40D0-840D-EFF3680D1547}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6A0B65CE-6B01-40D0-840D-EFF3680D1547}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{6A0B65CE-6B01-40D0-840D-EFF3680D1547}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{6A0B65CE-6B01-40D0-840D-EFF3680D1547}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{1976AC4A-FEA4-4587-A158-D9F79736D2B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1976AC4A-FEA4-4587-A158-D9F79736D2B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1976AC4A-FEA4-4587-A158-D9F79736D2B6}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
|
||||
|
|
@ -1138,7 +1126,6 @@ Global
|
|||
{62735776-46FF-4170-9392-02E128A69B89} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||
{EE1AB716-F102-4CA3-AD2C-214A44B459A0} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||
{C6E5AFFA-890A-448F-8DE3-878B1D3C9FC7} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||
{6A0B65CE-6B01-40D0-840D-EFF3680D1547} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||
{1976AC4A-FEA4-4587-A158-D9F79736D2B6} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||
{A192E504-2881-41DC-90D1-B7F1DD1134E8} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||
{61061528-071E-424E-965A-07BCC2F02672} = {16703B76-C9F7-4C75-AE6C-53D92E308E3C}
|
||||
|
|
|
|||
|
|
@ -9,11 +9,6 @@ using System.Net.Http;
|
|||
using System.Net.Http.Headers;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Mvc.Internal;
|
||||
using Microsoft.AspNet.Mvc.TagHelpers;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
|
|
@ -22,13 +17,8 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
IClassFixture<MvcTestFixture<HtmlGenerationWebSite.Startup>>,
|
||||
IClassFixture<MvcEncodedTestFixture<HtmlGenerationWebSite.Startup>>
|
||||
{
|
||||
private const string SiteName = nameof(HtmlGenerationWebSite);
|
||||
private static readonly Assembly _resourcesAssembly = typeof(HtmlGenerationTest).GetTypeInfo().Assembly;
|
||||
|
||||
private readonly Action<IApplicationBuilder> _app = new HtmlGenerationWebSite.Startup().Configure;
|
||||
private readonly Action<IServiceCollection> _configureServices =
|
||||
new HtmlGenerationWebSite.Startup().ConfigureServices;
|
||||
|
||||
public HtmlGenerationTest(
|
||||
MvcTestFixture<HtmlGenerationWebSite.Startup> fixture,
|
||||
MvcEncodedTestFixture<HtmlGenerationWebSite.Startup> encodedFixture)
|
||||
|
|
@ -56,6 +46,7 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{ "CreateWarehouse", null },
|
||||
// Testing the HTML helpers with FormTagHelper
|
||||
{ "EditWarehouse", null },
|
||||
{ "Form", "/HtmlGeneration_Home/Form" },
|
||||
// Testing MVC tag helpers invoked in the editor templates from HTML helpers
|
||||
{ "EmployeeList", null },
|
||||
// Testing the EnvironmentTagHelper
|
||||
|
|
@ -474,57 +465,6 @@ Products: Laptops (3)";
|
|||
Assert.Equal("Deal percentage is 30", response3.Trim());
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(null)]
|
||||
[InlineData(true)]
|
||||
[InlineData(false)]
|
||||
public async Task FormTagHelper_GeneratesExpectedContent(bool? optionsAntiforgery)
|
||||
{
|
||||
// Arrange
|
||||
var newServices = new ServiceCollection();
|
||||
var builder = new MvcCoreBuilder(newServices);
|
||||
builder.InitializeTagHelper<FormTagHelper>((helper, _) => helper.Antiforgery = optionsAntiforgery);
|
||||
var server = TestHelper.CreateServer(_app, SiteName,
|
||||
services =>
|
||||
{
|
||||
services.Add(newServices);
|
||||
_configureServices(services);
|
||||
});
|
||||
var client = server.CreateClient();
|
||||
var expectedMediaType = MediaTypeHeaderValue.Parse("text/html; charset=utf-8");
|
||||
|
||||
var outputFile = string.Format(
|
||||
"compiler/resources/HtmlGenerationWebSite.HtmlGeneration_Home.Form.Options.Antiforgery.{0}.html",
|
||||
optionsAntiforgery?.ToString() ?? "null");
|
||||
var expectedContent =
|
||||
await ResourceFile.ReadResourceAsync(_resourcesAssembly, outputFile, sourceFile: false);
|
||||
|
||||
// Act
|
||||
// The host is not important as everything runs in memory and tests are isolated from each other.
|
||||
var response = await client.GetAsync("http://localhost/HtmlGeneration_Home/Form");
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.Equal(expectedMediaType, response.Content.Headers.ContentType);
|
||||
|
||||
responseContent = responseContent.Trim();
|
||||
var forgeryTokens = AntiforgeryTestHelper.RetrieveAntiforgeryTokens(responseContent).ToArray();
|
||||
|
||||
#if GENERATE_BASELINES
|
||||
// Reverse usual substitutions and insert format items into the new file content.
|
||||
for (var index = 0; index < forgeryTokens.Length; index++)
|
||||
{
|
||||
responseContent = responseContent.Replace(forgeryTokens[index], $"{{{ index }}}");
|
||||
}
|
||||
|
||||
ResourceFile.UpdateFile(_resourcesAssembly, outputFile, expectedContent, responseContent);
|
||||
#else
|
||||
expectedContent = string.Format(expectedContent, forgeryTokens);
|
||||
Assert.Equal(expectedContent.Trim(), responseContent, ignoreLineEndingDifferences: true);
|
||||
#endif
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EditorTemplateWithNoModel_RendersWithCorrectMetadata()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,29 +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.Extensions.DependencyInjection;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.AspNet.Mvc.FunctionalTests
|
||||
{
|
||||
public class MvcStartupTests
|
||||
{
|
||||
private const string SiteName = nameof(AddServicesWebSite);
|
||||
private readonly Action<IApplicationBuilder> _app = new AddServicesWebSite.Startup().Configure;
|
||||
|
||||
[Fact]
|
||||
public void MvcThrowsWhenRequiredServicesAreNotAdded()
|
||||
{
|
||||
// Arrange
|
||||
var expectedMessage = "Unable to find the required services. Please add all the required " +
|
||||
"services by calling 'IServiceCollection.AddMvc()' inside the call to 'IApplicationBuilder.ConfigureServices(...)' " +
|
||||
"or 'IApplicationBuilder.UseMvc(...)' in the application startup code.";
|
||||
|
||||
// Act & Assert
|
||||
var ex = Assert.Throws<InvalidOperationException>(() => TestHelper.CreateServer(_app, SiteName));
|
||||
Assert.Equal(expectedMessage, ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,17 +2,12 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Mvc.Razor.Precompilation;
|
||||
using Microsoft.AspNet.Testing.xunit;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using PrecompilationWebSite;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -20,11 +15,6 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
{
|
||||
public class PrecompilationTest : IClassFixture<MvcTestFixture<PrecompilationWebSite.Startup>>
|
||||
{
|
||||
private const string SiteName = nameof(PrecompilationWebSite);
|
||||
private static readonly TimeSpan _cacheDelayInterval = TimeSpan.FromSeconds(1);
|
||||
private readonly Action<IApplicationBuilder> _app = new Startup().Configure;
|
||||
private readonly Action<IServiceCollection> _configureServices = new Startup().ConfigureServices;
|
||||
|
||||
public PrecompilationTest(MvcTestFixture<PrecompilationWebSite.Startup> fixture)
|
||||
{
|
||||
Client = fixture.Client;
|
||||
|
|
@ -32,59 +22,6 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
|
||||
public HttpClient Client { get; }
|
||||
|
||||
[ConditionalFact]
|
||||
[FrameworkSkipCondition(RuntimeFrameworks.Mono)]
|
||||
public async Task PrecompiledView_RendersCorrectly()
|
||||
{
|
||||
// Arrange
|
||||
IServiceCollection serviceCollection = null;
|
||||
var server = TestHelper.CreateServer(_app, SiteName, services =>
|
||||
{
|
||||
_configureServices(services);
|
||||
serviceCollection = services;
|
||||
});
|
||||
var client = server.CreateClient();
|
||||
|
||||
var serviceProvider = serviceCollection.BuildServiceProvider();
|
||||
var applicationEnvironment = serviceProvider.GetRequiredService<IApplicationEnvironment>();
|
||||
|
||||
var viewsDirectory = Path.Combine(applicationEnvironment.ApplicationBasePath, "Views", "Home");
|
||||
var indexContent = File.ReadAllText(Path.Combine(viewsDirectory, "Index.cshtml"));
|
||||
|
||||
// We will render a view that writes the fully qualified name of the Assembly containing the type of
|
||||
// the view. If the view is precompiled, this assembly will be PrecompilationWebsite.
|
||||
var assemblyNamePrefix = GetAssemblyNamePrefix();
|
||||
|
||||
try
|
||||
{
|
||||
// Act - 1
|
||||
var response = await client.GetAsync("http://localhost/Home/Index");
|
||||
var responseContent = await response.Content.ReadAsStringAsync();
|
||||
|
||||
// Assert - 1
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
var parsedResponse1 = new ParsedResponse(responseContent);
|
||||
Assert.StartsWith(assemblyNamePrefix, parsedResponse1.ViewStart);
|
||||
Assert.StartsWith(assemblyNamePrefix, parsedResponse1.Layout);
|
||||
Assert.StartsWith(assemblyNamePrefix, parsedResponse1.Index);
|
||||
|
||||
// Act - 2
|
||||
// Touch the Index file and verify it remains unaffected.
|
||||
await TouchFile(viewsDirectory, "Index.cshtml");
|
||||
responseContent = await client.GetStringAsync("http://localhost/Home/Index");
|
||||
|
||||
// Assert - 2
|
||||
var response2 = new ParsedResponse(responseContent);
|
||||
Assert.StartsWith(assemblyNamePrefix, response2.ViewStart);
|
||||
Assert.StartsWith(assemblyNamePrefix, response2.Index);
|
||||
Assert.StartsWith(assemblyNamePrefix, response2.Layout);
|
||||
}
|
||||
finally
|
||||
{
|
||||
File.WriteAllText(Path.Combine(viewsDirectory, "Index.cshtml"), indexContent.TrimEnd(' '));
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task PrecompiledView_UsesCompilationOptionsFromApplication()
|
||||
{
|
||||
|
|
@ -149,17 +86,6 @@ namespace Microsoft.AspNet.Mvc.FunctionalTests
|
|||
return typeof(Startup).GetTypeInfo().Assembly.GetName().Name + "." + nameof(RazorPreCompiler) + ".";
|
||||
}
|
||||
|
||||
private static async Task<string> TouchFile(string viewsDir, string file)
|
||||
{
|
||||
var path = Path.Combine(viewsDir, file);
|
||||
File.AppendAllText(path, " ");
|
||||
|
||||
// Delay to allow the file system watcher to catch up.
|
||||
await Task.Delay(_cacheDelayInterval);
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
private sealed class ParsedResponse
|
||||
{
|
||||
public ParsedResponse(string responseContent)
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Form</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Form Tag Helper Test</h2>
|
||||
|
||||
<form></form>
|
||||
<form action="/HtmlGeneration_Home/Form" method="post"><input name="__RequestVerificationToken" type="hidden" value="{0}" /></form>
|
||||
<form action="/HtmlGeneration_Home/Form" method="post"><input name="__RequestVerificationToken" type="hidden" value="{1}" /></form>
|
||||
<form action="/HtmlGeneration_Home/Form" method="post"></form>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Form</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Form Tag Helper Test</h2>
|
||||
|
||||
<form></form>
|
||||
<form action="/HtmlGeneration_Home/Form" method="post"><input name="__RequestVerificationToken" type="hidden" value="{0}" /></form>
|
||||
<form action="/HtmlGeneration_Home/Form" method="post"><input name="__RequestVerificationToken" type="hidden" value="{1}" /></form>
|
||||
<form action="/HtmlGeneration_Home/Form" method="post"></form>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -10,7 +10,6 @@
|
|||
"ActionConstraintsWebSite": "1.0.0",
|
||||
"ActionResultsWebSite": "1.0.0",
|
||||
"ActivatorWebSite": "1.0.0",
|
||||
"AddServicesWebSite": "1.0.0",
|
||||
"AntiforgeryTokenWebSite": "1.0.0",
|
||||
"ApiExplorerWebSite": "1.0.0",
|
||||
"ApplicationModelWebSite": "1.0.0",
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>6a0b65ce-6b01-40d0-840d-eff3680d1547</ProjectGuid>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<DevelopmentServerPort>49640</DevelopmentServerPort>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
||||
|
|
@ -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 Microsoft.AspNet.Builder;
|
||||
|
||||
namespace AddServicesWebSite
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public void Configure(IApplicationBuilder app)
|
||||
{
|
||||
app.UseCultureReplacer();
|
||||
|
||||
// Not calling AddMvc() here.
|
||||
// The purpose of the Website is to demonstrate that it throws
|
||||
// when AddMvc() is not called.
|
||||
|
||||
// Add MVC to the request pipeline
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
routes.MapRoute("areaRoute",
|
||||
"{area:exists}/{controller}/{action}",
|
||||
new { controller = "Home", action = "Index" });
|
||||
|
||||
routes.MapRoute("ActionAsMethod", "{controller}/{action}",
|
||||
defaults: new { controller = "Home", action = "Index" });
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
{
|
||||
"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"
|
||||
},
|
||||
"dependencies": {
|
||||
"Microsoft.AspNet.Server.Kestrel": "1.0.0-*",
|
||||
"Microsoft.AspNet.Mvc": "6.0.0-*",
|
||||
"Microsoft.AspNet.Mvc.TestConfiguration": "1.0.0",
|
||||
"Microsoft.AspNet.Server.WebListener": "1.0.0-*",
|
||||
"Microsoft.AspNet.StaticFiles": "1.0.0-*"
|
||||
},
|
||||
"frameworks": {
|
||||
"dnx451": { },
|
||||
"dnxcore50": { }
|
||||
},
|
||||
"webroot": "wwwroot"
|
||||
}
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
AddServicesWebSite
|
||||
===
|
||||
|
||||
This web site throws since the startup does not call AddMvc().
|
||||
|
|
@ -1 +0,0 @@
|
|||
HelloWorld
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.AspNet.Mvc.TagHelpers;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace HtmlGenerationWebSite
|
||||
|
|
@ -11,8 +12,10 @@ namespace HtmlGenerationWebSite
|
|||
// Set up application services
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
// Add MVC services to the services container
|
||||
services.AddMvc();
|
||||
// Add MVC services to the services container. Change default FormTagHelper.AntiForgery to false. Usually
|
||||
// null which is interpreted as true unless element includes an action attribute.
|
||||
services.AddMvc().InitializeTagHelper<FormTagHelper>((helper, _) => helper.Antiforgery = false);
|
||||
|
||||
services.AddSingleton<ProductsService>();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
<html>
|
||||
<body>
|
||||
<form asp-route-area="Customer" asp-controller="HtmlGeneration_Customer" asp-action="Index">
|
||||
<form asp-route-area="Customer" asp-controller="HtmlGeneration_Customer" asp-action="Index" asp-antiforgery="true">
|
||||
<div>
|
||||
<label asp-for="Number" class="order"></label>
|
||||
<input asp-for="Number" type="number" class="form-control" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue