โ About learning C# and Asp.net core
Hello guys, i wanna ask something about learning path to web development with c#.
I am learning C# for a while and haven't make any project yet i only followed courses and had theoretical knowledge.
So, when I can jump to asp.net, should I make projects with C# before, or can I learn C# better in Asp.net. I will learn C# for web development and as i see, there is no "plain C# backend" thing.
201 Replies
there is no "plain C# backend" thingwhat do you mean by this?
well, for example at frontend you can make a lot things with plain js without libraries or frameworks
you certainly can make a web backend without ASP.NET, but it will be extremely painful .
I highly recommend not even trying, as its not realistic. Unlike JS frontends where you have 10+ framework options, in .NET we have one serious option for backend development, and thats ASP.NET
yea my point is definitely that. I dont know should i start making projects with ASP.NET, or making projects with C#, maybe not related with web or yes.
I dont wanna use Forms or console apps, and my knowledge is so shallow at C#
I'd suggest learning the basics with console apps first
since it has a lower barrier of entry
but once you know classes, methods, variables etc, you can start with some simple stuff in ASP.NET
hmm so you are saying jumping into asp.net and learning c# with it is better
i mean learning that "diving deeper and being advanced", not basics
kinda.
I'd say it works, and if thats what you wanna do, do it.
But my concern is different
I often have 2 solutions open at a time: the (usually web) project im working on, and a console app "playground" for testing small concepts
I tried to work with asp.net core mvc razor project, (via copy-paste) it
Like a scratch pad?
and i saw different things which dont exists at tutorials and "basics courses"
like [] top of functions
Kinda.
and i saw different things at language docs which dont exists at tutorials like delegates, structs, records, etc
... you mean attributes? That's definitely in most asp tutorials
@pobiega yea, and other features like above. There is a thing like "some things not in tutorials" and like "some things only appear at asp.net"
You won't find every single language feature documented heavily in a random tutorial
i finished tutorials but i didnt see anything like delegate or records (C# language tutorials not asp.net)
and as i see, that things not used in asp.net
Records are extremely common in asp.net
Both records and delegates are just core language features they're not specific to asp.net but they're also not specific to win forms or console
for example if i give examples from javascript
there is nothing special to frameworks
everything is JS, and you can learn them when you finish a course or tutorial
That's not true either look at jsx and hooks from react for example
@pobiega yea but i mean you are still using js knowledge
hooks are functions for ex
How is that different in c sharp
i am trying to say "i finished C# tutorials and didnt see that things used at asp.net"
Just like I'm sure finishing a single reactorial won't teach you all the Advanced Concept there
is C# knowledge not enough to use ASP.NET we can say
Not sure what you are on about
people say "when you know javascript you can use any frameworks you want"
Basic http understanding and basic C# is all you need
Yeah but you'll still need to learn the frameworl
That's true for asp too
but for me its not true, i cant use any framework which i dk
hmm, so can we say "this is special for asp.net" like react hooks
In a way? Hooks are just functions, and asp actions are also just functions
But they behave a bit special
hmm
when i should jump to asp.net from c#
You can start once you know classes and methods
So quite early
But you will need to learn a lot of stuff in one way or another
actually there is C# 101 and 201, i finished C# 101 but it says advanced for 201 so i didnt look at that.
should i make projects with c# before jumping to asp.net, if so how those will be related with web without using asp.net
or maybe dont care asp.net and make things with c# to understand it better, then jump to asp.net
idk
Either is fine.
If you are exclusively interested in doing web stuff with C#; go directly to asp.net imo
but learning the fundamentals can be easier in a console app, until you are more familiar
i agree with Pobiega, i think u can jump to asp.net as u have most of the fundamental stuff learned now.
these
[Blah]
things are called attributes, there is not really a generic way to teach them as most libraries provide their own to give special meaning to what ever it attributes (methods, fields, properties, types, etc) and any not too shabby asp.net tutorial would explain them.
the only thing that didnt come up yet is async/await, but thats not really a requirement to get started either and tutorials will cover that along the road as wellactually i made an app with c# (asp.net core mvc), but its frontend was c# not javascript. and i dont know "how can i make a backend for a ready-made frontend with c# "
just make a web api
no frontend attached.
dotnet new webapi
records is more or less just fancy syntax stuff to avoid boilerplate.
and
public record MyDTO(int Id, string Name);
would be the same to give an example
struct
s u dont really have to care about they arent that common in web, as this is more for value types/optimizationsPlus it gives a lot of ruminations about how to handle records and file names ๐
and delegates are more or less just "method types", u will rarely write them urself, but mostly use some methods, eg. if u ever used linq, u most likely have passed lambdas as parameters, these will be converted to delegates:
these will become interesting once u start using databases (eg, entity framework)
yeah im not sure either
same when i declare my own delegates
but so far i still stuff them into their own files
(unless they r
file
scoped obviously)I usually just pack as many records in a single file as I can reasonably make sense of
but im also comming from the java world, so im used to it ๐
that project was (asp.net core mvc razor with ef core + postgres)
what a name ๐
i didnt learn anything while i was doing that but i learned "what is what"
one day ill take a look at ef core as well ๐ so far ive always written the sql queries myself ;p
but yeah, long story short, get started with asp.net ๐
it was a vacation to foreign country to me ๐
okay one more question about architecture
the only thing that didnt come up yet is async/await, but thats not really a requirement to get started either and tutorials will cover that along the road as wellalso it sounds like u have experience with js, so โคด๏ธ should be at least familiar
lets say i have a frontend project which finished, and i want to add a backend to it with c#
what i need to do
yea i have a lot things with async logic so far ๐
dotnet new webapi
thats it.first of all u need to know which end points the front end is calling and which DTOs (data transfer objects) it expects,
based on that u can start planning ur controllers and models.
but i would suggest that u start with a small simple project at first to get used to asp.net and how to structure it
will it be web api or razor mvc
i need a backend to connect my frontend
lets say a REST CRUD app
well, web api is basically a rest api, so its on u to decide. u can use webapi and simply write a single html file with embedded js for everything or use razor to render the html server side
rest is always web api
frontend will be js
i only need a thing can work itself
maybe i could be wrong, i think backend guys writing web api at most cuz there is a frontend which making with js
and my goal is being that backend guy which writes backend to a frontend
yeah its often the case that u write web apis, especially if it gets bigger and u have a micro service architecture
tho, there is also blazor, then u use c# for front end as well (i never touched blazor, and i think thats for now a bit too advanced for u as well)
https://jsonplaceholder.typicode.com/
i mean, when you think API it should give you some routes and data returned from those
as i know
linkedin api, maps api, yelp etc
so just make a webapi then
yeah, for those u use api controllers in asp.net ;p
(there is also minimal apis, but lets not touch that for now, especially as they are not that useful for most cases)
if i didnt have constraints to use js for frontend, i could pick c# for frontend definitely.
still do i need to work with mvc, razor or other things except web api
i rly hate GUI programming, why cant everything work via CLI T_T
is it enough only learning web api
defiinitely agree on that
I'm a professional C# backend developer, and I do not know MVC or Blazor or MAUI etc ๐
well web api is more or less MVC, just that ur view is always json ;p
I strictly do webapis in all flavors
forgive my level, maybe i am asking things not related with my concern
there is nothing to forgive
I think you should just get started
you seem to know what you want
โคด๏ธ
yea so far i didnt know what i want
now u do ;p
but problem is that command not solving anything ๐
wdym
it creates a new webapi project
you can then open it up in whatever editor you prefer and you're off to the races
https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-7.0&tabs=visual-studio here is a getting started tutorial for web api
Tutorial: Create a web API with ASP.NET Core
Learn how to build a web API with ASP.NET Core.
๐
here show begins
i dk asp.net ๐
the tutorial is exactly that ;p
but 90% of that is just normal C#
๐ normal C#, yea
methods, attributes, async/await, return types.. thats all normal C#
CreatedAtAction
is asp specific, HttpPost
is asp specific and ActionResult<T>
is asp specific
thats itc# tutorials didnt teach me those
๐
work through that tutorial and if u r stuck u can ask on this server for help ๐
I mean, does your first ever action need to involve a database call?
maybe start out with just an endpoint returning "hello world"
If I have never cooked food in my life, should the first dish I make be a beef wellington?
I've never went out for a jog, lets run a marathon?
start small
dont dive in at the deep end without knowing how to swim
this is my all concern
i think starting with web api dont save me
okay so
dotnet new webapi
thats all you need to do
it creates a default template
including an existing simple controller
you can look at that and see whats going on
then make your own
if you have questions, you can ask them
but for the love of god, dont expect a tutorial to handfeed you every single bit of information you needno no i m sure everything ll be good when i learn asp.net
my concern was how can i add a backend to my frontend
now go, travel and explore the wastelands to find the treasures of knowledge by try and error *heartly send off*
and now i know how
i only need a thing which exposes routes and gives some data
/todos/{id} etc
thats a controller.
yep my view will js
i dont need model
thats fine. its still a controller.
the controller is what wires the front end's requests to the backend's business logic, at least one of these define the api surface
totally
what you guys think about connecting next.js with asp.net core
probably fine. will need a reverse proxy thou?
i have barely any knowledge about vanilla js, so i cant say anything about that
since next.js includes SSR stuff
i dont even know
my plan is connecting my backend to next
but i dk its doable or forbidden
doable, not forbidden
get started and think about it later ;p
today i learned 3 things
with your great help
- asp.net is advanced c# and has specific features like classes, interfaces etc
- i need to play well with c# before jumping to web
- for beginning i only need a web api with only controllers returning some dummy data, but for WEB API concept, first i need to learn asp.net at a good level
asp.net is advanced c# and has specific features like classes, interfaces etc i need to play well with c# before jumping to webthis is like the opposite of what we said but okay
you said you can play with asp.net as you know c#
but i realized my c# is not enough to play with asp.net yet
its not advanced C# thou, and "classes and interfaces" are not unique to asp lol
they are FUNDAMENTAL core concepts of C# in general
i mean async, linq, ef
thats also general C# stuff
none of it is asp specific
i dk why but i didnt learn those
because you did a "introduction to C#" course
ah yes
it wont introduce everything in a fairly large language
i think i need to finish 201 before
maybe more
not really
you can learn all of that as you go
its not a requirement to get started
cuz this looks like a thing which i cant understand properly
thats a unittest lol
i can read, understand but with my TS knowledge ๐
first i ll learn C# things
thanks guys
especially your patience and time (tho its a default thing when dealing with c# lol ) ๐
but i didnt get one thing
do i need a DB or sth to make a web api
examples saying yes, but i dont know how to work with DB
no, but it wont be a very useful api without one
looks like i have to deal with console apps again ๐
why?
https://jakeydocs.readthedocs.io/en/latest/tutorials/first-web-api.html
"first web api"
๐
dont follow that lol
it recommends fiddler ๐
i dont even know what is fiddler ๐
actually i wouldnt ask this question at all
its a bit like postman
except its a mitm
okay i wanna ask you honest question
then i ll disappear
lets say you want to test a route ex: localhost:5000/api/test and it ll only return a string or json
one route,
you ll make a curl to it, and it gives you result
what would be your "minimal, painless" way to achieve it ๐
for ease it only includes GET
one function, one controller
sure
wgimmie 1 sec, healing a dungeon :d
wow
in fact, do you wanna watch me do it live?
the api
no i only need way
like a food recipe
chop, cook, serve
it doesnt have to be extensive or detailed
like this
From the File menu, select New > Project.
Enter Web API in the search box.
Select the ASP.NET Core Web API template and select Next.
but not that detailed
start a new template, delete redundant stuff, edit here like that and done
im not doing that lol
dotnet new webapi
remove weatherforecast controller and its model
create a new controller
done
this is my controller
this is my "Program.cs"
thats it
all the code in the entire project
I didnt write a single line in program.cs, thats the defaulthmm
and look
it comes with swagger by default
awesome
my pain was "learning C# to reach a level which i can do that easily"
was all I wrote myself. I could have looked at the example controller and copied the attributes from there
i am sure you are getting me
maybe i am looking that so noob
๐
if you want "write another route which accepts post request with id" from me
i cant
when i look that i only see that for now
got it
i saw a thing like
public IActionResult Index() { return View() }
View()
is for MVC controllersi am feeling i got what i want and keepin you busy still ๐
this is an api controller, it doesnt have views
dont get me wrong
can also do stuff like
i can read and understand this syntax
looks like this when called
yeah, and this is what a simple webapi looks like
the examples you showed were all for more complicated setups with databases and async code
and yes, you will need to learn that eventually
but to start, you dont
hmm
this changes everything
lets look at this code
from microsoft tutorial
i cant read this with my current knowledge
why
Task<IActionResult>
is it default, or variable say i can write Task<MyClass>
etc
maybe its related with i know c# but not asp.net
i can understand what it is doing, but i dk how to write thatso
Task
, async
and await
are all related to async code
Task is like Promise
from js/ts
IActionResult
is an untyped http response
it lets us return 204 or 404
or any other http code
my code above only ever returned 200 or 500[ValidateAntiForgeryToken]
๐
but am not asking that
its okay
eventually most apps require auth layer
its better to finish that 201 lessons asap
then i ll start to learn asp.net with its own tutorials
thankfully microsoft thought this already
because of i am not good at "backend logic" and c#, things being complex to me but its okay
i can handle this when i learn
๐
thanks again, i enjoyed besides learning
not that different :p
like "god why" right
its just that C# doesnt do anonymous types, so we declare a Movie type
life is so weird right
but i can say this "even c# looks more complex, still writing it gives confidence and enjoy"
Type thing = new Type();
feels me like carving onto stone
๐
explaining it to 5
have you worked with TS @pobiega
yup.
i realized its more extended than c#
"extended"?
so far i was thinking c# is harder than ts
the TS typesystem is crazy to be honest, but it has to be since it tries to support javascript
but it has a lot of nice things, like discriminated unions
the inventor of both saying same
i made a monster ๐
the inventor of TS is the same guy who made C#
you know that right?
yep
one side people inventing 3 languages
other side i am trying to understand its type systems ๐
wish people can use TS for backend
uhm
you can
thats what I used it for.
cuz now i am forcing myself to learn C#, even i know TS
in my country most of companies working with C# at backend
so i have to learn it
anyways accept my apologies to ruin your day with my questions
hope i can ask questions related with code after some time
good luck
back (sry had to water the plants and feed the animals)
so any questions left to answer or r u set for ur journey?
wish people can use TS for backend
we re here
if i know well, i could write a thing like asp.net but TS to favor of humanity
but unfortunately TS is not popular like C# when it comes backend
i cant edit that
wow php is still that widely used, didnt expect that, but i guess that also includes the small "home pages" with not too much functionality
bingo
i guess that also includes the small "home pages"
my first steps in web dev were in php, but that was back in 2005 or so ๐
PHP is trivial to host
thats a huuuuuuuge part of why its so big
yeah, free php + mysql hosting (with some ads on it) was a thing back then. ofc i used some js and css to get rid of the ads xD
i wrote a lil calendar app back then where my class mates and me could upload the home work ๐
when i look that 3 graph, i want to ran away from coding
.. okay?
Feel free to.
I hope noone is forcing you to code against your will
i doubt these charts r correct
esepecially the cobol thingy
most popular stack is looking like MERN
but when i look at first one, it becomes C#
good cobol devs make like.. 3 times what other devs make here
since there is like 12 of them in the entire country
when it comes salary TS devs more than C#
yeah, because there r like 3 cobol experts left in the world ๐
I highly doubt that
also, where the fuck are these numbers from?
stackoverflow
do u have a link?
so its an average
and in the SO surveys, you pick multiple languages
ie, I can say I'm a TS/C# dev
Stack Overflow
Stack Overflow Developer Survey 2023
In May 2023 over 90,000 developers responded to our annual survey about how they learn and level up, which tools they're using, and which ones they want.
and I guess my salary contributes to both averages
also dont forget that c#/asp.net is still on quite a stable rise, it hasnt been long since it went xplat
i want to believe i am doing good with learning C#
u do
but also have a feeling why i am not going with js
its not a mutually exclusive choice
most people know and use multiple languages
I personally use primarily C#, but I also use TS, Rust, F# and Kotlin
after some time it doesnt really matter. once u understand how the interna works, its more about learning the language specific quirks and their bcl/stdlib/whatever they call it in that language
in my life i touched c, c++, pascal, java, kotlin, c#, rust, python, php, i think im missing some
oh groovy as well but that was mainly for gradle scripts
js too
VB, PHP, C#, ActionScript, C, C++, java, D, JS, python here, in addition to what I mentioned above.
and some shorter experiments with stuff like haskell, scala, ocaml
TS i never touched but thats mainly because i stopped my minimalistic front end crap
https://danielyxie.github.io/bitburner/ is my primary usecase for TS lately ๐
most of the languages i mainly tried back then for a chat bot system for a mmorpg because i wanted updates to plugins during runtime and platform independent, i started with java and did quite a round trip to end up with java (OSGi framework) again. still thinking about writing it in c# but instead with a micro service architecture xD
but the game is dead any way (its release was in 2001)
2001... its not Dark Age of Camelot is it? that game didnt have plugins for aaaages.
but thats actually the reason I went into C#
Anarchy Online from Funcom
the first OSS server emulator for DAoC was in C#
oooh, AO. Nice.
i stopped playing last year, but there i was already multi boxing (playing with 6 accounts simultanously) to help the community get some raids done
there r like 100 ppl max online at the same time, so its more or less going down
and FC didnt even care about exploiters that used item duping etc
the multi box wasnt really a concern for them as u still had to pay for each account (~110โฌ per year per acc)
we... should take this somewhere else xD
;D
actually im going to play some osu for now, unless i find something interesting in the other channels
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.
Was this issue resolved? If so, run /close
- otherwise I will mark this as stale and this post will be archived until there is new activity.