Enhancing your Web API: Part 1 | ASP.NET Core 101 [8 of 13]

preview_player
Показать описание


Learn more about ASP.NET:

Follow us:

Useful Links:
Рекомендации по теме
Комментарии
Автор

For those who are confused about the "[controller]" routing resulting in "Products": [controller] is seemingly a non case sensitive token that will result in the name of the controller class minus the sufix "controller". It's not really all that well explained especially for a 101 tutorial tbf.

hungryhedgehog
Автор

As others have said, this tutorial is a delight to follow along with. You're also explaining things in a way that is both in-depth and easy to understand for those of us who are new to the html world.

nicke
Автор

I don't understand the part between 8:00 and 8:15 - how did we end up with json when the GetProducts() method only returns IEnumerable<Product>. You mention that manual json serialization isn't needed because we already put it in the product service.. except we didn't. The product service only had a deserializer.. not a serializer. What am I missing?

surakshachoudhary
Автор

how does the controller know to serialize into Json form or use the WriteAsync function if you havent told it to do that

toxicbullets
Автор

the information being shared is good it's a no-brainer, but they really had me at "talking smack" - of course. the slang is so next level and her "TTYL" volley after receiving his"TCB" smash... downright exquisite. rock on.

cbrown
Автор

I had to google what TTYL means, I was so confused like him.
Thanks for the series, talk to you later.

kiocpm
Автор

0:49 why don't use await keyword in return

rahmatabadi
Автор

I had issues adding a controller, it seems that many on the web did too, the error thrown is "There was an error adding selected code genertator: 'Package restore failed..' To avoid this issue, instead of using the short cut to add a controller, choose add a new item, then choose 'Controller class' in the Add New Item window, using this method works, using the direct short cut did not for me. I'm using the latest VS2019 as of 20 Dec 19.

trevlivingstone
Автор

when the routing was done via endpoints in the startup.cs IEnumerable<product> was serialized and returned context.Response.WriteAsync(), but while using controller IEnumerable<product> was returned. Why serialization was not done?

deepakd
Автор

Good Morning,
great tutorial, but why do you have to add the controller as a service? I didnt get that and therefore i commented the line out and it still works.

lukasschmitt
Автор

The 2 presenters are a delight to follow.
They remind me of my coworker (white male) and I (black female) when we are programming together. It's all Fun Unlimited, indeed. :)

nachannachle
Автор

why do we need an api if we have already told our system about our JsonProductFileService in our startup services in video 5. We then create a new API service and announce that in startup aswell. is there some reason why the original service wouldnt be accessible but this new API is? It seems like we are just doing the same thing with extra steps.

toxicbullets
Автор

I'm really confused as to where does it actually say that the api is accessible by typing /products next to the url

KMauserBYF
Автор

Thank you for this intro tutorial. I am having the following error message, and I wonder if you can point in the right direction for a solution. Thanks!
JsonException: 'a' is invalid after a single JSON value. Expected end of data. Path: $ | LineNumber: 138 | BytePositionInLine: 1.

• in JsonFileProductService.cs

-

39. {

40.

41. using (var jsonFileReader = File.OpenText(JsonFileName))

42.

43. {

44.

45. return JsonSerializer.Deserialize<Product[]>(jsonFileReader.ReadToEnd(),

46.

47. new JsonSerializerOptions

48. {

49. PropertyNameCaseInsensitive = true

50. });

51.

• in Index.cshtml.cs

-

23.

24. public JsonFileProductService ProductService { get; }

25. public IEnumerable<Product> Products { get; private set; }

26.

27. public void OnGet()

28. {

29. Products = ProductService.GetProducts();

30. }

31. }

32. }

dkyosk
Автор

It makes a huge difference coming from the folks who made the tools. So clean, concise, and no black boxes. Love it. Quesiton - you mentioend that the [Route("[Controller")] tag is providing the endpoint name "/products", but it's unclear to me where the name "products" is declared. Is this some kind of magic happening under the covers that peals off "Controller" from the class name? - actually just answered my own qustion: yes. That's exactly what's happening. It just parses out whatever preceeds "controller" from your class name

truthByFire
Автор

The controller worked without adding it to the services. Why did we add it to the services if we are not injecting it anywhere?

mov
Автор

FOR PEOPLE ON MACS => when they add the new controller, you can't do it the way they show - it is hidden under "Add New Scaffolding" - there you get the options to add the controller pages. Why it is different I don't know, but there it is xD

JBJProgramming
Автор

Did anyone have problems with adding a controller? I can't add a controller as shown in the video. I would like to know my problem if anyone volunteers to help.

onuriltas
Автор

I love you guys🤩...this serie is very useful for me🎉🎉👌👏👏...TCB!! 🤣🤣😂😂😂

ManiasInc
Автор

Thank you very much, although my language is bad, I still understand and have the motivation to learn, teaching in detail is easy to understand and to the point. not roundabout. Sincerely thank

openit