diff --git a/1-aspnet-introduction-slides.html b/1-aspnet-introduction-slides.html index 0d57db6..edc687e 100644 --- a/1-aspnet-introduction-slides.html +++ b/1-aspnet-introduction-slides.html @@ -13,11 +13,14 @@ /* buutti.css */ /* @theme buutti */div#\:\$p>svg>foreignObject>section .columns{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:calc(var(--marpit-root-font-size, 1rem) * 1)}div#\:\$p>svg>foreignObject>section .columns12{display:grid;grid-template-columns:1fr 2fr;gap:calc(var(--marpit-root-font-size, 1rem) * 1)}div#\:\$p>svg>foreignObject>section .columns21{display:grid;grid-template-columns:2fr 1fr;gap:calc(var(--marpit-root-font-size, 1rem) * 1)}div#\:\$p>svg>foreignObject>section .columns32{display:grid;grid-template-columns:3fr 2fr;gap:calc(var(--marpit-root-font-size, 1rem) * 1)}div#\:\$p>svg>foreignObject>section .columns23{display:grid;grid-template-columns:2fr 3fr;gap:calc(var(--marpit-root-font-size, 1rem) * 1)}div#\:\$p>svg>foreignObject>section .columns111{display:grid;grid-template-columns:1fr 1fr 1fr;gap:calc(var(--marpit-root-font-size, 1rem) * 1)}div#\:\$p>svg>foreignObject>section .centered{display:flex;flex-direction:column;justify-content:center;text-align:center}div#\:\$p>svg>foreignObject>section .tableborderless td,div#\:\$p>svg>foreignObject>section th{border:none!important;border-collapse:collapse}div#\:\$p>svg>foreignObject>section.extra{background-color:#5d275d;background-image:linear-gradient(to bottom,#401a40,#1d0c1d);color:white}div#\:\$p>svg>foreignObject>section.extra a{color:rgb(145,255,209)}div#\:\$p>svg>foreignObject>section.exercise{background-color:#29366f;background-image:linear-gradient(to bottom,#20636a,#173742);color:white}div#\:\$p>svg>foreignObject>section.exercise a{color:rgb(211,173,255)} -/* @theme 8lh3rjev3cpwiqc307miuofc8u1wrc5dagzppz442 */div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]{columns:initial!important;display:block!important;padding:0!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]:after,div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]:before,div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=content]:after,div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=content]:before{display:none!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container]{all:initial;display:flex;flex-direction:row;height:100%;overflow:hidden;width:100%}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container][data-marpit-advanced-background-direction=vertical]{flex-direction:column}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background][data-marpit-advanced-background-split]>div[data-marpit-advanced-background-container]{width:var(--marpit-advanced-background-split,50%)}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background][data-marpit-advanced-background-split=right]>div[data-marpit-advanced-background-container]{margin-left:calc(100% - var(--marpit-advanced-background-split, 50%))}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container]>figure{all:initial;background-position:center;background-repeat:no-repeat;background-size:cover;flex:auto;margin:0}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=background]>div[data-marpit-advanced-background-container]>figure>figcaption{position:absolute;border:0;clip:rect(0,0,0,0);height:1px;margin:-1px;overflow:hidden;padding:0;white-space:nowrap;width:1px}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=content],div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=pseudo]{background:transparent!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background=pseudo],div#\:\$p>svg[data-marpit-svg]>foreignObject[data-marpit-advanced-background=pseudo]{pointer-events:none!important}div#\:\$p>svg>foreignObject>section[data-marpit-advanced-background-split]{width:100%;height:100%}
Install-Package Swashbuckle.AspNetCore -Version 6.6.2
@@ -131,7 +134,7 @@
Program.cs
includes the following lines:builder.Services.AddControllers();
@@ -150,7 +153,7 @@ builder.Services.AddSwaggerGen(); // add th
WeatherForecastController.cs
in the Controllers folder
@@ -204,8 +207,11 @@ builder.Services.AddSwaggerGen(); // add th
Program.cs
Program.cs
Program.cs
file in ASP.NET 7 is where the services for the web application are configured and the middleware is definedvar builder = WebApplication.CreateBuilder(args);
@@ -219,7 +225,7 @@ builder.Services.AddSwaggerGen(); // add th
WeatherController.cs
[ApiController] // Attribute routing requirement,
- // automatic HTTP 400 response, and more
-[Route("[controller]")] // HTTP GET requests are routed to this method
+- In ASP.NET, attributes have a strong role in routing:
[ApiController] // Attribute routing requirement,
+ // automatic HTTP 400 response, and more
+
+[Route("[controller]")] // URIs with "/weatherforecast" are routed to this class
public class WeatherForecastController : ControllerBase
{
//...
-}
-// ...
-[HttpGet] // URIs with "/weatherforecast" are routed to this class
-public IEnumerable<WeatherForecast> Get()
-{
- //...
+ [HttpGet] // HTTP GET requests are routed to this method
+ public IEnumerable<WeatherForecast> Get()
+ {
+ //...
+ }
}
WeatherForecastController.cs
so that the forecast result is printed atYou can see the route change in the Swagger UI GET
method.
HttpGet
Requests[Route("api")]
@@ -376,7 +385,7 @@ instead of

[Route("api")]
@@ -396,7 +405,7 @@ instead of

:
404
status code[HttpGet("products/{id:int}")] // Required type: int
@@ -408,8 +417,8 @@ instead of

GET
method so that instead of returning an IEnumerable
of WeatherForecast
objects, it returns a List
of string
objects.
@@ -424,8 +433,11 @@ instead ofPOST
requests cannot be made with the browser's address bar, only GET
!POST
requests are usually made with formsGET
, POST
, PUT
and DELETE
Run the Weather API program, and test both methods with Postman.
APIs are interfaces that applicaitons use to communicate with each other +
APIs are interfaces that applicaitons use to communicate with each other Xamarin for mobile Use of NuGet packages add modularity and decrease the minimum memory footprint of your projects