28 points · by invalid_arg · 13y ago · 49 comments
No its not.
"If you don't need all the ways you can customize ASP.NET MVC"
Nancy is pluggable at pretty much any point. You don't like the way routing works in Nancy, plug it. Don't like the base module, plug it.
Nancy is far more extensible than WebAPI or MVC.
Having said that, anything you can do in WebAPI / MVC you can do in Nancy, and anything you can do in Nancy, you can do in WebAPI / MVC
Nancy just has a nicer API.
In your opinion.
A lot of older developers don't like the Func<>iness of some of these newer frameworks. Just something to consider.
He does know about WebAPI.
They both have differences, and are equally valid choices. Aside from anything else, I give Nancy time because I'd love to see more open source independent development on the .NET platform.
Its routing is rubbish - waiting for V2 for fixed routing (AttributeRouting support so its not hidden away)
Its terrible to extend.
Its slower than Nancy.
Its hard to test out of the box.
Guess what, your website is an API, it just happens to return text/html instead of some other format you specify. If you use MVC and WebAPI, you're doing it wrong.
Also...
http://weblogs.asp.net/shijuvarghese/archive/2013/07/30/writ...
vs
http://www.marcusoft.net/2013/01/NancyTesting3.html
Sums up WebAPI for me.
SpringMVC + JAX-RS1/2
RoR + Sinatra
A web-app using some framework + NodeJS for API
There's nothing wrong with that as you may want to have different models or different configurations (throttling or whatnot).
Using MVC-based framework for your API endpoint is overkill.
WCF's only benefit is TCP bindings. If you're doing any HTTP stuff, stay clear of WCF.
Your issues with it might have more to do with you.
Odd that the two single replies I got are a couple of bulldogs desperately shooting any alternative to this submission down.
Nancy is cool and i'd definitely consider using it in the future but for now, it was easier to port over our api from MVC4 to a much more familiar structure.
Forms auth is done by calling this.RequiresAuthentication(); you can implement an extension method to do an ApiKey check in about 5 lines of code :)
- content negotiation (basic building block of hypermedia APIs),
- authentication (and ensure SSL is used when authenticated),
- most importantly, HTTP caching, where
-- unauthenticated users get cached content, authenticated users don't,
-- vary on representation negotiations (media type, encoding, and language),
-- cache is located on server and in browser.
In other words, take basic advantage of HTTP to improve security and performance. Taken together, the requirements listed above comprise a problem of only moderate complexity, and are fundamental to flexible, high performance web apps. Accomplishing it in ASP.NET MVC/Web API is painful and relies on the inconsistent, malfunctioning, horrifically designed ASP.NET response caching module.
Show me a framework that does the above and makes it reasonable to build hypermedia APIs, and you've got yourself a convert.
For entering the code, I am using my favorite (programmable) text editor and believe it is working very well. Otherwise I use some scripts I've written in my favorite scripting language.
To do this development I read through about a cubic foot of books and 4000+ Web pages of documentation, nearly all from Microsoft's Web site.
For the development I struggle some with 'scope of properties' in CSS (which apparently is nearly never discussed) and much of the documentation, but otherwise from the server farm architecture to the computing to be done down to the lines of code and documentation, there are no problems. E.g., for a single Web page, say, X, there is a file X.ASPX, and it has some options, some static HTML and CSS, some 'event handlers', e.g.,
Sub Page_Init
Sub Page_Load
Sub Page_PreRender
Sub Page_Unload
some Visual Basic
code, a lot of use of classes from
ASP.NET, ADO.NET, etc., and
some include files for CSS,
functions, classes, etc. Fine.And I don't have even as much as a weak little hollow hint of a tiny clue what MVC is or why I should want or need it. The explanations of just why I should want MVC look to me as burdensome and totally meaningless distinctions and constructions for no good reason. Same for a 'framework'. Same for Nancy and everything else in the OP.
E.g., the OP talks about GET and POST "methods". I don't do those things -- IIS and ASP.NET handle those for me. If I want the actual post data, then it's available to me via some ASP.NET classes. But the code I write doesn't deal very directly with GET or POST.
And have I found no good explanation of why I shouldn't just continue as I am.
I don't have a clue what OP is talking about.
My guess is that MVC, Nancy, etc. are for programmers with backgrounds in Web development on Linux who want to program on Windows and there use programming tools and techniques they used on Linux instead of just the usual Windows IIS, ASP.NET, etc.
I've already read a cubic foot of books and 4000+ Web pages of documentation, and my work is going fine; why should I junk my work to date, read a lot more documentation, involve myself in more overhead of tools instead of just going my real work?
More documentation can have errors; more tools can take me farther from the real data and can have bugs.
Am I doing something seriously wrong?
You might be absolutely fine not knowing those things, but at some point down the road you are going to be lacking some essential knowledge of how HTTP works. To put it simply: everything - Ruby, PHP, ASP.NET, you name it - uses GET and POST requests underneath it all. Learning about them would be of great benefit to you in the long term.
A slightly inaccurate analogy: you can make a perfectly functional web site with Dreamweaver, and not touch a single HTML tag. It'll work fine, until it doesn't, and then you're going to be in a lot of trouble. Given that you don't know what's going on underneath Dreamweaver's GUI, your only option will be to keep hitting 'undo' until it works again.
Same for a 'framework'. Same for Nancy and everything else in the OP.
ASP.NET WebForms is a 'framework', too. They're just different frameworks. WebForms, as the name suggests, is particularly good at creating forms- it has numerous abstractions to help you maintain state. It's great for intranet data gathering/presentation stuff. But the pages are very, very heavy, loaded down with code that never gets used. So it has pluses and minuses. Just like MVC and Nancy.
Some things like making an endpoint that servces json and xml responses is almost trivial on Nancy or ServiceStack, easy in ASP MVC with WebApi, and a pain in webforms.
From what I understand, what I'm using is lighter weight than MVC or anything else being discussed here. So far, I see no problems with what I'm doing.
E.g., for the MVC architecture, I have a server farm and software architecture, and it's simple and more than enough.
> You might be absolutely fine not knowing those things, but at some point down the road you are going to be lacking some essential knowledge of how HTTP works. To put it simply: everything - Ruby, PHP, ASP.NET, you name it - uses GET and POST requests underneath it all. Learning about them would be of great benefit to you in the long term.
Right. But I do understand GET and POST, and, again, via some classes in ASP.NET have access to that data, including raw, if I want it. Occasionally I considered looking at the raw data but too quickly found ASP.NET classes that had the data I wanted already all parsed, etc. in properties of the classes; I don't think I've touched the raw GET/POST data yet.
Yes, ASP.NET does some things for me, e.g., ViewState, which took a while to understand. Okay.
I didn't like the way ASP.NET and IIS handled user session state so just grab a GUID, convert it to a string, put it in a hidden field, and send it to the user. Then on postback, I get the GUID, and that's my session ID for that user. That session ID, just as the string is the key in a little key-value store I wrote as a separately running Visual Basic .NET console application using class instance de/serialization, TCP/IP, and two instances of a .NET collection class (hopefully AVL trees or red-black trees). The key-value store is single-threaded so doesn't need to use the concurrent versions of the collection classes. Timings indicate that on a 3.0 GHz single core processor, the store should be able to send or receive 2000 key-value pairs a second, enough to send 1000 Web pages a second.
As far as I know, I don't really use Web Forms. I use placeholders, tables, buttons, and text boxes via static HTML and/or the corresponding ASP.NET classes. ASP.NET builds a big tree of all the 'controls', etc., and at 'render time' does apparently a depth first traversal of the tree and scribbles out the corresponding static HTML to send to the user. And if ASP.NET wants to send the user some JavaScript, it writes and sends that, too -- so far have yet to write a single character of JavaScript. Fine with me.
So far my Web pages are next to dirt simple and, with the JavaScript, send from my server (not counting data from ad servers) for about 400,000 bits each. Likely much of the JavaScript is boilerplate and can be shrunk, but that's for later. I have no pull-downs, pop-ups, or roll-overs; each screen is exactly 800 pixels wide; there is some simple text, a few simple images, some push buttons and text boxes, all arranged in tables for layout. Some of the screens have to be a bit dynamic so get generated in loops in Visual Basic code and are not just static HTML, but the only dynamic part is the number of rows in some tables -- we're still talking simple.
I guess, "If it ain't broke, then don't fix it.".
That said, I love C#, I like ASP.NET MVC, and I absolutely loathe WebForms and VB.NET. Everything about those technologies feels clunky and wrong-headed to me, as if I have been forced to run a race with my arms strapped to my sides. Having learned about HTTP, HTML, and core JavaScript a long time ago, WebForms seems an awkward, highly annoying abstraction that hides the knobs I want to turn while presenting me with hundreds of different knobs about which I don't want to learn.
While not quite so bad, the syntax of VB.NET fills me with unease... everything seems cleaner, clearer, smarter in C#. VB.NET shouts "the author of this code doesn't really like to write code" in the same way that a Prius announces "the owner of this car doesn't like motorsports."
> presenting me with hundreds of different knobs about which I don't want to learn
I certainly haven't been using lots of such knobs. Nearly everything I do in VB.NET and ASP.NET is obviously quite close to really simple HTML and CSS.
As far as I can tell, C# and VB.NET are equivalent ways, different essentially only in syntactic sugar, to get to the basic .NET classes and common language runtime (CLR). C# seems to want to borrow from the especially succinct syntax of C/C++ which I don't like. I prefer the more verbose syntax from the history of Fortran, Basic, PL/I, etc.
E.g., I have essentially no idea what MVC is, what it's for, why one should use it, etc. Similarly for WebForms. Then similarly for Nancy, etc.
So far, my Web pages work fine.