Skip to content

Instantly share code, notes, and snippets.

@rodolfofadino
Last active October 8, 2018 19:00
Show Gist options
  • Save rodolfofadino/3ab95c97b7c720cdd6bfa2698bf67e8a to your computer and use it in GitHub Desktop.
Save rodolfofadino/3ab95c97b7c720cdd6bfa2698bf67e8a to your computer and use it in GitHub Desktop.
fiap-2018-02-aula-01

Aula 1

Instalando o Package

Install-package Microsoft.ASPNETCore.All

ou

dotnet add package Microsoft.ASPNETCore.All

passo 1

public static IWebHost BuildWebHost(string[] args)
{
    return WebHost.CreateDefaultBuilder(args)
        .UseStartup<Startup>()
        .Build();
}

passo 2

public class Startup
{

}

passo 3

public class Startup
{
	public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
	}
}

passo 4

public class Startup
{
		public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            app.Run(async (context) =>
            {
                await context.Response.WriteAsync("Ola Fiap!!!");
            });
        }

}

passo 4

BuildWebHost(args).Run();

Corrigindo o SDK

##MVC Middleware

passo 5

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    app.UseMvc();
}

passo 6

public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc();
}

passo 7

app.UseMvc(routes =>
{
    routes.MapRoute(
        name: "default",
        template: "{controller=Home}/{action=Index}/{id?}");
});

passo8

public class HomeController : Controller
{
    public  string  Index()
    {
        return "olá Fiap";
    }
}

passo 9

public  IActionResult  Index()
{
    return View();
}

passo 10 Index.cshtml

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body>
    <h1>Olá Fiap</h1>
    
</body>
</html>

passo 11

<nav>
        <ul>
            <li><a href="#">Home</a></li>
            <li><a href="#">Sobre</a></li>
        </ul>
</nav>

passo 11 _ViewStart.cshtml

@{
    Layout = "_Layout";
}

passo 12 _ViewStart.cshtml

@{
    Layout = "_Layout";
}

passo 12 _layout.cshtml

<article>
        @RenderBody()
</article>

passo 13

<img src="" />

passo 14

app.UseStaticFiles();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment