How can I implement my own version of a MVC framework in ASP.NET? - asp.net

I would like to know how I can go about implementing my own version of a MVC framework in ASP.NET? I know there already is Microsoft provided ASP.NET MVC framework, but I want to learn MVC and thought the best way would be to implement my own flavor of a MVC framework on top of ASP.NET. Any thoughts / guidance ?
Also, can anyone point me to a page where I can learn more about how microsoft implemented ASP.NET MVC ? I'm more interested in learning about the under the hood plumbing that goes on to implement the framework on top of asp.net, do they use HttpHandlers / HttpModules ?
Thanks.

You want to learn about a concept by reinventing an existing framework that already does that concept better than you will? That sounds like quite a rabbit hole to venture into.
Why not learn MVC by learning ASP.NET MVC? What's your reasoning for why that's not a valid way to learn the concepts? Learning a proven framework will be a much better approach than what you're considering.
EDIT: One other thing to consider. Knowing how to use ASP.NET MVC (or Rails, or insert-MVC-framework-here) would be a much more useful and marketable skill than the ability to roll your own MVC framework from scratch (even though that might prove more intellectually stimulating).

You can get the source for ASP.NET MVC from here: http://aspnet.codeplex.com/releases/view/41742

MVC is an architectural pattern that is not dependent on ASP.NET or any framework.
I would not advise trying to implement it on top of ASP.NET if you are just looking to learn about the Model View Controller pattern. ASP.NET will impose too many implementation details when you should instead be concentrating on the overall concept such as separation of concerns, single responsibility.
The ASP.NET MVC framework is simply an implementation of the Model View Controller pattern that runs on top of ASP.NET. Like most implementations it contains variations on the basic MVC pattern to better suit web applications and the underlying framework. So trying to re-implement ASP.NET MVC will give you a non-standard understanding of the pattern.
Martin Fowler explains the fundamental ideas of MVC in the book: Patterns of Enterprise Application Architecture.

Related

Should I use ASP.NET MVC or ASP.NET 4.0 webforms

We are planning to start a new asp.net web based application in a few weeks. We have three members in our team all with experience in asp.net 2.0
We are jumping direct from asp.net 2.0 to 4.0 (skipping 3.5) and we were discussing, should we go for asp.net 4.0 webforms or should we learn/develop in asp.net MVC? However, we don't have any prior MVC experience.
If you guys think that MVC is the way to go then please recommend good books using C#.
As with all engineering decisions, it depends.
Is your timeline long enough that you can ride the learning curve? Is everyone OK with learning MVC, or are you going to get blowback? Does your team know and understand HTML and CSS? I know this seems like a silly question, but a lot of ASP.NET WebForms programmers get by without really understanding the concepts for quite some time.
Do you want to make pervasive use of Ajax and CSS? Does anyone know JQuery or one of the other JS frameworks and want to make the best of them? Is unit testing important to you?
If the answers to these questions are, in general, "yes", then I would recommend taking the plunge and going for ASP.NET MVC over WebForms. As far as a book goes, I'll leave that to others. I still have not found a book that I really like yet.
I know that I'm pretty much an exclusive ASP.NET MVC programmer for new projects going forward. IMO WebForms is a broken and outdated model. Viewstate is painful for developers and web services, and postbacks are painful for users.
If you are comfortable with and know Web Forms well, use those.
Generally, use the tool you are most comfortable with.
My suggestion is: if you are tight scheduled and development team is experienced with web forms 2.0, your choose should be web form. It is nothing so serious happend between 2.0 and 4.0 that you might loose competence. Web forms still web forms.
If you have month or so as buffer to get in into MVC, you should do that. It is more natural for web development, and what I like - more testable.
I'm personally not to quick to rewrite my applications on MVC 2.0, and even start new project with MVC.. Maybe I wait for 3.0 version :)
A lot of information is here:
http://www.asp.net/mvc
A also got sources of Mvs2inaction (please google for Mvc2inaction and be pointed to github site)
And sure you have to check Phil Haack blog.
(sorry could not post a lot of links yet))
As others have answered already about what to choose between Web Forms and MVC, if you have decided to go for MVC you can find book recommendation in following links -
https://stackoverflow.com/questions/1281726/good-asp-net-mvc-vb-books (Although the questions is about VB books but answers are for both)
https://stackoverflow.com/questions/1942068/best-resources-books-for-asp-net-mvc-framework-closed
Also I would like to recommend one new book which I have just started to read. This is good for understanding the concepts and compares Web Forms and MVC.
Programming Microsoft ASP.NET MVC - Dino Esposito

What are some of the must know concepts in ASP.NET?

I am giving a small presentation to a group of Java developers and looking for some core areas to target. Ideally I would like to only talk about the core concepts in ASP.NET.
I am coming up with
Authentication
Session State
ASP.NET MVC
LINQ (more .net)
Any more that I should be considering?
One of the most important things to learn is the ASP.net lifecycle. It makes debugging much more worthwhile...
For ASP.net WebForms -
MSDN Documentation
Useful cheat sheet
It is important to keep the life cycle in mind when developing web based applications.
I'd focus on ASP.NET MVC (because while MVC is bread and butter in Java, that's a pretty cool implementation) and LINQ, especially the runtime query construction you can do with something like PredicateBuilder (because Java can't do that and it's a very good way to demonstrate the unique capabilities of C#).

Does asp.net MVC depends on Normal asp.net

this is my first question Here ,
I am a beginner in asp.net , and i want to make a CMS project using it
After Some readings I found that the MVC structure is very suitable for Me
Just want to know :
how much the asp.net MVC depend on the normal asp.net??
as a beginner i don't know the level of knowledge for Normal asp.net to start working using asp.net MVC
Please tell me where to start in the normal asp.net(3.5) and when to switch to learn the asp.net MVC ??
Detailed information is very welcome
Thanks For your Time
It is built on normal ASP.NET minus postbacks, viewstate, and event wiring. The underlying System.Web stuff is the same, but with some new wrappers to access it, and of course a bunch of new featuers that make up the MVC portion. Just get a book on ASP.NET MVC, and don't worry about classic ASP.NET.
'normal' (also known as WebForms) asp.net and 'mvc' asp.net are somewhat different from each other in how things are put together and how things work with each other. There is no need to learn one before learning the other.
If you read through this article you can see at a glance what the differences are between 'normal' or WebForms and 'mvc'.
Here is a pretty good tutorial for learning about MVC from Scott Guthrie if this is the way that you're leaning.
Good luck and have fun!
It depends on what you mean by "ASP.NET". ASP.NET MVC does depend on standard ASP.NET request processing pipeline (IHttpModules, IHttpHandlers and all other internal workings), but it does not depend on WebForms infrastructure.
I've recently jumped on the ASP.NET MVC bandwagon and I found the introduction tutorials on the official http://asp.net/mvc site very useful.
ASP.NET WebForms tried to mimic WinForms desktop apps in that you have controls and event-driven interaction, which is not particularly well suited to the stateless HTTP
ASP.NET MVC gives you full control over the HTML that is generated and sent back to the browser, but more importantly, it makes it easier to write testable code.
Also, ASP.NET MVC does not depend on ASP.NET WebForms, they are built on the same foundation. In fact, in principle, you can mix and use both in the same app if you really wanted to :)
When MVC was released, what used to be simply ASP.NET was renamed ASP.NET Webforms and MVC because ASP.NET MVC. Not sure if that answers your question but it does clear up some terminology.
Why not start with Asp.Net MVC ?
Asp.Net is split now into 2 parts. Webforms and MVC.
I'd advise looking at the following -
http://bloggingabout.net/blogs/mischa/archive/2008/02/04/asp-net-mvc-vs-asp-net-webforms-vs-ruby-on-rails.aspx
http://nerddinner.codeplex.com/

What is the best ASP.NET MVC framework/architecture and why?

There are a number of frameworks out there for building ASP.NET MVC applications (e.g. sharp architecture, etc...)? In defining what a framework is, I'm thinking along the line of Ruby on Rails ... a stack of technologies that enable you to build all tiers of your application quickly, efficiently and with both testability and quality in mind.
So, in your humble opinions ... which is the best and why?
In particular I'm looking for an architecture that supports an RIA type front-end that takes full advantage of JQuery and/or ExtJs on the client.
IMHO the ASP.NET MVC framework is the best framework at the moment. The reason? Well, basically it is the only framework I've tried that allows you to depart completely from the WebForms methodology. Please note that I have tried a relatively few number of MVC frameworks and it's not like I'm saying that the ASP.NET MVC framework is perfect or anything.

Asp.net MVC Question regarding n-tier

I have studied a lot of starter kits for ASP.NET and ASP.NET MVC really is awesome compared to web forms, because it runs fast and developement is easy. But when I fit ASP.NET MVC, LINQ in a site with a lot of visitors and mostly controls based website, I got so many issues in my mind.
Let's say I want to build a website which is small scale, but got a lot of visitors and mostly controls based (i.e. TV Show Information website). You've got shows, episodes.
Is it efficient and easy when you use n-tier architecture in ASP.NET MVC?
Should I create my own entities in Business Logic Layer or use SQL Tables as entities?
Should I use Application Cache in it to save all shows in cache?
I like the Presentation Layer of MVC using LINQ but when it comes to DataAccess and BusinessLogic its confusing me. Can anyone help?
My 2 cents:
In my opinion there is no difference between using ASP.Net MVC or Web Forms in an N-Tier architecture. We use WCF to comunicate between tiers.
We create Data Transfer Objects that are not the Entity Framework Entities. However, I expect this to change with the next version of Entity Framework which introduces POCO.
Not sure what you mean by "shows". ASP.Net has its own caching for pages, for caching data you could use Enterprise Library.
Just to clarify I define a Tier as a separate machine, where as a layer would be a separate dll.
i've just read an amazing article regarding working n-tier with asp.net mvc
check it out:
http://www.codeproject.com/KB/aspnet/ASP_NET_MVC_WITH_EF.aspx
it's all about right architecture working with ASP.NET MVC Framework + N-tier + Entity Framework
enjoy!
:-Dan
I highly recommend the NerdDinner ASP.NET MVC Tutorial. You can get more info on it and download the free chapter from ScottGu's blog post here.
In the code that accompanies that sample chapter there is a pretty good architecture structure that you can use to base your architecture on. I have gone back to it several times when trying to see how to architect something in ASP.NET MVC.
Have you built your first application in ASP.NET MVC yet, or are you still studying?
I think you should start with an architecture similar to NerdDinner and refactor after you become more familiar with how ASP.NET MVC works.
If you really are well versed in multi-tier, then you should be able to figure it out without help from us. Try some things. Do what works. Try not to worry so much about being "correct."
Some of what you are asking in your question is premature if you haven't written your first ASP.NET MVC application yet.
By the way, I found Scott Hanselman's "File/New/NerdDinner" video both enlightening and entertaining: http://videos.visitmix.com/MIX09/T49F
I use my own flavor of n-Tier with MVC because I don't like LINQ-to-SQL and the Entity Framework. I've also written some T4 templates that generate those objects and the use the Enterprise Library to interact with the DB. It's up to you, whatever works.

Resources