Witam. Mam tak wygląda plik Startup.cs:
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace WebApp1
{
public class Startup
{
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddRazorPages();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapRazorPages();
});
}
}
}
A tak HomeController.cs:
using Microsoft.AspNetCore.Mvc;
namespace WebApp1
{
public class HomeController : Controller
{
[HttpGet]
public IActionResult Get()
{
return View("Index");
}
[HttpPost]
public IActionResult Post()
{
return View("Index");
}
}
}
No i jeszcze tak Index.cshtml:
@page
@model object
@{
Layout = null;
}
<!DOCTYPE html>
<html lang="pl">
<head>
<title>STRONA GŁÓWNA</title>
</head>
<body>
<div>
Witaj na stronie głównej!
<form method="post">
<input type="submit" value="Wyślij żądanie POST">
</form>
</div>
</body>
</html>
Strona ładuje się pod localhost:5001/, jednak gdy wcisnę przycisk wysyłający żądanie post, to otrzymuje HTTP ERROR 400. Dlaczego?