Код: Выделить всё
using Microsoft.AspNetCore.Mvc;
using ControllersExample.Models;
namespace ControllersExample.Controllers
{
[Controller]
public class HomeController : Controller
{
[Route("/")]
[Route("home")]
public ContentResult home()
{
return Content("Welcome Hello from Index", "text/html");
}
[Route("about")]
public string about()
{
return "Hello from about";
}
[Route("contact")]
public string contact()
{
return "Hello from contact";
}
}
}
Код: Выделить всё
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllers(); //add all controller classes as services
var app = builder.Build();
//app.MapGet("/", () => "Hello World!");
app.UseStaticFiles();
app.UseRouting();
app.MapControllers();
app.Run();
Я попытался добавить < /p>
Код: Выделить всё
app.Use(async (context, next) =>
{
await context.Response.WriteAsync("Page not found");
await next();
});
Спасибо всем заранее
Подробнее здесь: https://stackoverflow.com/questions/794 ... r-requests
Мобильная версия