98 Replies
halp
Well you're only listening on
http://
so
Also, any errors?I WANT HTTPS
not http
Why do you listen on HTTP twice, then?
port compatibilty
you need a certificate for https
HttpListener Class (System.Net)
Provides a simple, programmatically controlled HTTP protocol listener. This class cannot be inherited.
And you need to actually listen on HTTPS
Or better yet, depending on what you're trying to make, just use ASP
aspΒΏ?
Yes, the web framework for C#
ASP.NET Core
And how i do it
i have no idea, also this is terribly outdated, we are talking windows xp here
you can start by reading the doc ZZZ shared
I mean, HttpListener isn't outdated, it just has some very limited uses
well you are right
very niche xd
You can configure Server Certificates and other listener options by using Network Shell (netsh.exe). See Network Shell (Netsh) for more details. The executable began shipping with Windows Server 2008 and Windows Vista.
read the documentationhttps://stackoverflow.com/questions/11403333/httplistener-with-https-support here's something on making your own certs
Do mind, that they're per-domain and that includes the port
You can't make a catch-all certificate
Y just want to make my http listener secure
:c
i got error
makecert.exe doenst exist
Use one of the answers: https://stackoverflow.com/a/33905011/6042255
Stack Overflow
Httplistener with HTTPS support
There seems to be a lot of confusing, sometimes conflicting, information with regards to making a .NET HTTPListener HTTPS capable. My understanding is as follows:
One's C# code needs an https pref...
You can use
openssl
instead
Or perhaps even PuTTy key generatorsdasdsa
If you have Git installed (which you should) OpenSSL comes with it
i dont
You can easily correct this mistake
why is so dificult π«
and on node express its just all auto
Well it would be automatic if you used ASP
But you decided to reinvent the wheel and rawdog it from bare HttpListener
on ASP.NET Core httplistener is betteR?
There's no
HttpListener
It's very low-level
ASP is a more high-level frameworkand how i do a https listener on thath
You don't
Why would you?
because i want to do a server?
Well, ASP does just that
You're too stuck on that HttpListener
Forget it exists
Forget you ever learned about it
If you want an API, use a WebAPI project. Then you'll be able to just declare a controller and an actiona nd it will just work
If you want something closer to Express, use a Minimal API project
i want it local and on c#
And it'll be the same. Define a route, return a response, works
So?
Everything I mentioned is C#
Everything I mentioned can run locally
umm
umm
first one
ye i know
and this
i coould send the files
and run it on other computer?
What do you mean?
Yes, you can publish it to an executable and run it elsewhere
Yes, you can zip up the project files and compile and run it elsewhere
ummm
umm
The first one, yeah
umm
Idk what any of that says but looks good enough
"something something https" is checked, so that seems fine
ummm
There you go
i have absolutly no idea of how this works
umm
No clue what it says
Agree to whatever it is
You can check "no volver la pregnant" if you deem it necessary
thats the self signed certificate
?
click yes
oye como se llama ese editor
There you go, it works now
visual studio?
pense que era otro
trust ASP.NET Core SSL Certificate
but i just wanted like express watch on x port only and handle request and run some code befor
no this strange manager page
or this is just auto gernerated
look at minimal apis maybe?
by the projedxt
It's not a strange manager page, it shows you what endpoints you have in your app
You can remove it if you want
(and that strange manager page only shows if you're compiling for debug, by default)
Just delete anything with
Swagger
in your Program.cs
i think he can get rid of the endpoint explorer services as well in that case
in VS, you will also want to edit launchSettings.json to disable launching the browser (assuming you remove Swagger)
ammm
it's self explanatory
All that matters is the
Controllers
folder tbh
Make a new controller class there
Add action methods
Boomhe said he wants something like express, in which case https://learn.microsoft.com/en-us/aspnet/core/tutorials/min-web-api?view=aspnetcore-7.0&tabs=visual-studio
Tutorial: Create a minimal API with ASP.NET Core
Learn how to build a minimal API with ASP.NET Core.
this is perfect
but im seeing thath aspnet core web api is for big apis
like realy big and complex ap
it's for any web api
like that example, that's about the smallest "api" you can make
Well, yeah, APIs are generally large and complex, so the WebAPI has proper ways to handle that complexity
The minimal API is, well, minimal
the DI framework is amazing ^
Di framworkΒΏ
Dependency injection - .NET
Learn how to use dependency injection within your .NET apps. Discover how to registration services, define service lifetimes, and express dependencies in C#.
Dependency injection
googleβ’οΈ
Swagger is like a very big debugger for apis
right?
no
it's a documentation tool
And lets you make requests to those endpoints without the need for a client like Postman
yea and when exceptions ocuress has like a full stack of erros
That's always a thing
When an exception happens in C#, you get the stack trace
yea but it swows on the web
that's just asp.net core
in development mode you get detailed error pages if an exception is thrown
how i configure the port
launchSettings.json in VS :p
oh
Well, the settings files in general
VS or not
localhost is 127.0.0.1
not your private ip
oh
i forgot it :c
still not working
what do you want to do
acess to api from my phone
to computer
change localhost
to 0.0.0.0
curl: (60) schannel: SNI or certificate check failed: SEC_E_WRONG_PRINCIPAL (0x80090322) - The destination principal name is incorrect.
google
i need to go now
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.stil having ssl errors
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.