Install-package Microsoft.ASPNETCore.All
dotnet add package Microsoft.ASPNETCore.All
public static IWebHost BuildWebHost(string[] args)
{
return WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.Build();
}
public class Startup
{
}
public class Startup
{
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
}
}
public class Startup
{
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.Run(async (context) =>
{
await context.Response.WriteAsync("Ola Fiap!!!");
});
}
}
BuildWebHost(args).Run();
##MVC Middleware
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseMvc();
}
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
}
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
public class HomeController : Controller
{
public string Index()
{
return "olá Fiap";
}
}
public IActionResult Index()
{
return View();
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<h1>Olá Fiap</h1>
</body>
</html>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Sobre</a></li>
</ul>
</nav>
@{
Layout = "_Layout";
}
@{
Layout = "_Layout";
}
<article>
@RenderBody()
</article>
<img src="" />
app.UseStaticFiles();