Hacker News new | ask | show | jobs
by mattmanser 4994 days ago
MVC is actually pretty damn clunky. It has a lot of built-ins which are just frustrating (like IPrincipal, ugh). Also there are loads and loads of weird quirks that pop up as soon as you start trying to do anything like returning JSON.

MVC was a huge step forward from the old ASP.Net, but it's still making a lot of frankly odd decisions or suddenly bizarre behaviours in the background (e.g. http://stackoverflow.com/questions/1975983/how-can-i-disable...)

I think one of the reasons node.js is so great is that it just cuts out almost everything and gives you direct control over what is returned. MVC still mucks around with everything trying to be 'helpful' as it's really built on ASP.Net in the background.

To many of us, javascript is still one of the worst mainstream language around today.

Still, why not just make node.cs instead one wonders? Perhaps the existing ecosystem.

4 comments

I personally find those "helpful" things to be truly, well, helpful. For example the input validation, anti-forgery token validation, simple cache control, etc.

Again, not saying you can't do these things in node. The two technologies can easily accomplish the same goal. But if your primary concern is avoiding JS, why would you choose a technology that is built entirely upon it?

Node.cs might make more sense, I agree. I have a feeling the existing ecosystem might bring its own problems with the author's approach, because your C# code may have trouble integrating with those existing libraries, if the underlying generated code does not behave as the Javascript library expects.

FWIW, I've found NancyFx[0] fairly non-clunky as far as .NET goes. It's more of an analogue for Sinatra than Node.js, though.

[0] https://github.com/NancyFx/Nancy

Agreed, if you're forced to use C#, Nancy at least does it sanely (and RESTfully!).
can you elaborate on the quirks around returning JSON with asp.net MVC? its a pretty common usecase.
There's a load of little things that are gotchas, but an example that pops into my head is that it wasn't compatible with default jQuery for example. If you didn't ask specifically for a content-type of application/json, which jQuery didn't by default, it would throw a hissy fit. It meant mucking around with the ajax object meaning you couldn't use certain jQuery shortcut methods. Regardless of what you 'told' MVC to do.

So there's a bunch of things it's doing you're not even aware that it is nor have asked it to do.

Think that was MVC 3? I've been using it since the first version, it's much better than it started (the original JSON support was awful), but you still every now and then get a WTF moment.

For example I still really have no idea the 'right' way to return 404 or 500 error pages. I swear they change their mind every release.

By default MVC 4 will return JSON so you don't need to specify the content-type unless you want something that isn't JSON.
It's not the return type, it was the request type. It didn't like if you requested it with plain/text instead of application/json. Which was jQuery's json method's default.
plain/text gives you JSON in MVC 4. I understood what you were saying, the default in MVC 4 is now to return JSON unless you specify otherwise.
Yeah, but this is my whole point. Finally in version 4 they stop mucking around with the requests before they give it to you. Someone, somewhere in the depths of MS clearly believe they understand HTTP better than you do. And keep guessing what you really 'meant'.

Even though they quite clearly don't understand and actually really don't get HTTP. For example take the fact that it's nigh impossible to get the actual request body in ASP.Net. Who's bright idea was that?

In reality every single interface, every single framework they've produced so far has shown a woeful lack of understanding about the web in general and pretty much how it's used outside their world. And I say this as someone who's primarily programmed in VBScript, VB6, C#, Silverlight, ASP.Net and ASP.Net MVC.

I keep almost jumping ship and then they just kinda fix it and I stick around hoping they're not going to make the same mistakes. But they do, jeesus, MVCs ajax stuff is unsurprisingly fucking awful.

But that's the problem with MVC and anything MS led, they don't get the web, they don't get javascript, they keep making incredibly silly decisions.

A good example. Every time I hear 'unobtrusive' js, I just want to scream. They're the cause of this made up problem. No-one else was doing js like that in 2010, no-one else needed unobtrusive javascript. Just MS. There's no such thing as unobtrusive javascript, there's just not writing idiotic magic code like a fucking retard like MS constantly do when it comes to javascript.

And don't even get me started on their 'web services' or WCF. Both deserve to die in a fire.

TL;DR; I love C#, think it's the best language available today by far. I hate asp.net though.

The biggest thing I can think of is how it defaults to throwing an exception when attempting to return JSON for a GET request. You could disable this easily enough, but I never understood the rationale behind the decision, and it was a momentary frustration every single time. Hopefully they've changed that in MVC 4.
There is an exploit made possible by returning 'unwrapped' json in response to GET's. This details it fairly nicely: http://haacked.com/archive/2008/11/20/anatomy-of-a-subtle-js...
What's wrong with IPrincipal, which btw is a .NET, not MVC thing?