model binding

main
syneffort 2 years ago
parent 4699e3981e
commit ef66c15aad
  1. 25
      BlazorApp/AspNetCoreMVC/Controllers/HomeController.cs
  2. 13
      BlazorApp/AspNetCoreMVC/Models/Models.cs
  3. 14
      BlazorApp/BlazorServerApp/BlazorServerApp.csproj
  4. 7
      BlazorApp/BlazorServerApp/Dockerfile
  5. 7
      BlazorApp/RankingApp/Dockerfile
  6. 14
      BlazorApp/RankingApp/RankingApp.csproj

@ -20,9 +20,30 @@ namespace AspNetCoreMVC.Controllers
//return Redirect(url); //return Redirect(url);
return RedirectToAction("Privacy"); //return RedirectToAction("Privacy");
//return View(); return View();
}
public IActionResult Test(int id, [FromHeader] string value)
{
return null;
}
public IActionResult Test2(TestModel testModel)
{
if (!ModelState.IsValid)
return RedirectToAction("Error");
return null;
}
//1) names[0]=Faker&names[1]=Deft
//2) [0]=Faker&[1]=Deft
//3) names=Faker&names=Deft
public IActionResult Test3(List<string> names)
{
return null;
} }
public IActionResult Privacy() public IActionResult Privacy()

@ -0,0 +1,13 @@
using System.ComponentModel.DataAnnotations;
namespace AspNetCoreMVC.Models
{
public class TestModel
{
[Required]
public int Id { get; set; }
[Required]
[StringLength(20)]
public string Name { get; set; }
}
}

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
@ -6,4 +6,16 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<None Include="..\.dockerignore" Link=".dockerignore">
<DependentUpon>$(DockerDefaultDockerfile)</DependentUpon>
</None>
</ItemGroup>
<ItemGroup>
<None Update="Dockerfile">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project> </Project>

@ -0,0 +1,7 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0
COPY . /app
WORKDIR /app
EXPOSE 80
ENTRYPOINT ["dotnet", "BlazorServerApp.dll"]

@ -0,0 +1,7 @@
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
FROM mcr.microsoft.com/dotnet/aspnet:6.0
COPY . /app
WORKDIR /app
EXPOSE 80
ENTRYPOINT ["dotnet", "RankingApp.dll"]

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
@ -7,6 +7,12 @@
<UserSecretsId>aspnet-RankingApp-4c431b3d-01c0-4833-aa25-9114e95a5131</UserSecretsId> <UserSecretsId>aspnet-RankingApp-4c431b3d-01c0-4833-aa25-9114e95a5131</UserSecretsId>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<None Include="..\.dockerignore" Link=".dockerignore">
<DependentUpon>$(DockerDefaultDockerfile)</DependentUpon>
</None>
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="6.0.20" /> <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="6.0.20" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.20" /> <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.20" />
@ -20,4 +26,10 @@
<ProjectReference Include="..\SharedData\SharedData.csproj" /> <ProjectReference Include="..\SharedData\SharedData.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Update="Dockerfile">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project> </Project>

Loading…
Cancel
Save