|
|
|
|
using AspNetCoreMVC.Models;
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
|
|
|
|
namespace AspNetCoreMVC.Controllers
|
|
|
|
|
{
|
|
|
|
|
public class HomeController : Controller
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger<HomeController> _logger;
|
|
|
|
|
|
|
|
|
|
public HomeController(ILogger<HomeController> logger)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Index()
|
|
|
|
|
{
|
|
|
|
|
//string url = Url.Action("Privacy", "Home");
|
|
|
|
|
//string url = Url.RouteUrl("test", new { test = 123 });
|
|
|
|
|
|
|
|
|
|
//return Redirect(url);
|
|
|
|
|
|
|
|
|
|
//return RedirectToAction("Privacy");
|
|
|
|
|
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Test()
|
|
|
|
|
{
|
|
|
|
|
TestViewModel viewModel = new TestViewModel()
|
|
|
|
|
{
|
|
|
|
|
Names = new List<string>()
|
|
|
|
|
{
|
|
|
|
|
"One", "Two", "Three"
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return View(viewModel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IActionResult Test1(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()
|
|
|
|
|
{
|
|
|
|
|
//int a = 1;
|
|
|
|
|
//int b = 3 / (a - 1);
|
|
|
|
|
|
|
|
|
|
ViewData["Message"] = "Data from privacy";
|
|
|
|
|
return View();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
|
|
|
|
|
public IActionResult Error()
|
|
|
|
|
{
|
|
|
|
|
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|