News for hackers. Stuff that matters.
Re:Performance Improvements in .NET 7 by cerved on Wednesday August 31, 2022 @01:31PM (#32665581)
Http request handling in asp.net mvc. The uri, type and parameter serialization is a magic mess.

How do you PUT { "foo" : { "bar" : "baz" }} to ping/pong/yolo?

You create a controller class, PingController, you create a method PutPong, then you give up and proceed to cry blood

Re:Performance Improvements in .NET 7 by guhidalg on Wednesday August 31, 2022 @02:02PM (#32666008)
It seems you had a bad time learning ASP.NET, but in my experience what you're asking for is not difficult at all.

You have to: 1. [Optional] Define a DTO that deserializes { "foo" : { "bar" : "baz" }} to an object 2. Write a class that subclasses Controller 3. Write a method, call it whatever you want, that accepts a JObject or one of your DTO types. 4. Add the attribute [HttpPut("ping/pong/yolo")] to tell the framework this method should be bound to PUTs for that path. 5. Write your business logic.

Is that blood-crying inducing? No.

Re:Performance Improvements in .NET 7 by cerved on Thursday September 01, 2022 @04:27AM (#32673577)
Without decent documentation, it is.
Re:Performance Improvements in .NET 7 by aliswe on Wednesday August 31, 2022 @01:55PM (#32665891)
something like

app.MapPut("ping/pong/yolo", ctx => ...);

and in there you read the Body as string ... it should be a one liner?

Re:Performance Improvements in .NET 7 by neonsunset on Wednesday August 31, 2022 @10:02PM (#32670960)
app.MapPut("ping/pong/yolo", ([FromBody] Payload request) => {...});

record Payload(Foo Foo);

record Foo(string Bar);

or

app.MapPut("ping/pong/yolo", (JsonElement json) => {...});

Basically, just avoid outdated blog posts and articles :D

Re:Performance Improvements in .NET 7 by cerved on Thursday September 01, 2022 @04:28AM (#32673588)
this looks like asp.net core
Re:Performance Improvements in .NET 7 by neonsunset on Thursday September 01, 2022 @07:36AM (#32674958)
No one in their sane mind would use ASP.NET for new projects (it is legacy and a business risk) nowadays so it's reasonable to assume that everyone means ASP.NET Core given the .NET 7 context.
Re:Performance Improvements in .NET 7 by cerved on Thursday September 01, 2022 @05:08PM (#32683218)
the context was asp.net mvc specifically
Re:Performance Improvements in .NET 7 by metaltyphoon on Thursday September 01, 2022 @10:42PM (#32685995)
ASP.NET MVC is dead. It has been over 6 years; you need to update yourself.