MVC or Webform Architecture for new site - c#

I'm developing a website , job portal. I have 2-3 years of ASP.NET webform development experience,
I want to create a professional job portal site (to improve and learn more) but trying to decide on best architecture. Any suggestions or advice will help...
Thanks

Well, there are a number of ways to answer this question, and I'm sure many others will chime in. I'll just say that since your goal is to improve and learn more, and you already have 2-3 years of webform experience, this might be a good opportunity for you to learn MVC. Then you will have experience in both, and can make more informed decisions regarding the best architecture for future projects.
Happy learning!

Whilst nobody can tell you exactly what to do, the team I manage is about to release a new CMS / Job portal using ASP MVC. MVC gives us excellent testability and scalability out of the box and it can be quickly combined with tools such as nHibernate / windsor (IOC) / nCache / jQuery - this ensures that you have a wealth of resources on the internet to help accelerate your development and skill. You can also embrace standards such as XHTML 1.1 strict, which is almost impossible with ASP.Net webforms due to the auto generated HTML
1 other advantage is that you also get away from the dreaded ASP.Net viewstate.

Use ASP.NET MVC if you want to:
learn the ASP.NET MVC framework
use jQuery or similar libraries
really learn web-languages (HTML, CSS, JavaScript)
use Test Driven Development
have a clean separation of concerns
If you don't have the time or will to learn to use the ASP.NET MVC framework correctly, stick with ASP.NET WebForms.

My answer is almost always "ASP.NET MVC." The amount of flexibility and features and testability and maintainabilty and ... heavily outweigh WebForms.
WebForms has the advantages of a rich ecosystem of existing controls and documentation, and is really powerful for some kinds of tasks (complex, multi-form interactions), but I find its limitations get in the way far too often. You have to mold yourself to it.

It really depends on what the end goal of the application is. As Scott Ewers said, if your goal is to learn, then using ASP.NET MVC will expand your breadth of knowledge in the ASP.NET space (since you already know web forms).
Additionally, if this is going to be a public product, you can leverage the testability benefits of MVC and run automated unit tests. Key ideas like Separation of Concerns can also increase long-term scalability and maintainability.
The primary reason why you might choose web forms is if you are rapidly prototyping the job board application. As you know, web forms allows you to drag-and-drop components onto the canvas to quickly create some basic data entry functionality.

There is a herding code podcast from May 13 on the subject.
Herding Code 47: Joe Brinkman on Webforms vs ASP.NET MVC.

I also agree that choosing MVC would have the advantage of allowing you to expand your knowledge. That not being the only reason, given the choice as well I just finished a small MVC project (my first) and let me tell you MVC rocks! Its a great framework which I feel gives you more flexibility and at the same time out-of-the-box tools to create a web app quickly and painlessly. It was my first experience with VS2008 & .NET FW 3.5 & LINQ, and all the guides at www.asp.net helped me go forward quickly (especially the free tutorial chapter from an MVC 1.0 book mentioned here).
I also got to learn JQuery along the way, as it is very much integrated into these new technologies.
One think to take note though is that this being a new tech, version 2 is already being cooked up, so if your project is for the long run, have that in mind and plan accordingly (in my case, being a small project, I'll probably try upgrading my project to version 2 when its officially released). Yet at the same time, having a fully MS (and thus MSDN) supported version 1 was a godsend for me...
Good luck!

I have good experience in Jquery, CSS, HTML, Javascript but not in TDD.
I have time..and willing to learn MVC but wasn't sure MVC is good choice for Job portal or similar site..

This can be considered a shameless self-advertisement but here is my quiz on how to choose between the two:
http://sietch.net/ViewNewsItem.aspx?NewsItemID=101

I was recently tasked by one of my clients to write a paper, or simply a checklist, that would help other lead developers make this same decision.
I posted the first 2 rough drafts on my blog. I am admittedly pro-mvc but the paper/checklist has been we received so it might be helpful.
http://eric.polerecky.com/archives/a-somewhat-less-biases-comparison-of-mvp-and-mvc/[http://eric.polerecky.com/archives/a-somewhat-less-biases-comparison-of-mvp-and-mvc/][1]
I think the most often overlooked benefit of MVC is convention; I really see any convention in webforms projects and while not strictly enforced in MVC projects at least its there.

i started developing our current app in webforms, mvc wasn't available when development started.. i've chosen the MVP pattern, with URL rewrite HTTP module. currently i'm investigating plugging in some MVC into this, basically to use the front-controller instead of using page-controllers. the other things in already established MVP architecture with web forms in my app give me more flexibility than pure MVC approach without WebForms, which i like, although require a bit more code than MS MVC examples (never tried it for real project to see if it stays that way, like in those examples in screencasts).
what i don't like with MVC is mixing control code inside templates - i believe loops, ifs and stuff like that just shouldn't belong inside the template. but a couple days ago i've ran into Spark view engine that looks kind of promising in that segment, although not still close to the Tapestry 5 (a component-based webGUI framework) in the java world.
But the above mention suggestion to mix both might work for you to explore MVC world and have the safe ground to fallback to if something won't work for you might be ok for you.

Related

Improving A Legacy ASP.NET WebForms Project to Modern Standards

I was given a project in WebForms to make robust and I had so far added several improvements to it. Don't get me wrong, I like WebForms for its simplicity but much of it is I feel like 'grandfather' type of coding.
Here's what I did, just to give you some ideas:
1.) Added VueJS to the frontend
2.) Added Webpack and a bit of ReactJS to on some pages
3.) Used .NET core on running a custom protocol app that triggers from inside the WebForms project
4.) I've added an emailing function (Inbox, Sent Items, Drafts, Trash, Junk, etc.) (from WebForms and jQuery, another one was WebForms + VueJS) to it as well.
It has gotten pretty big. I was just wondering if it will be scalable? Our management is thinking of putting it on the cloud soon but I believe it wouldn't work because of the architecture of our project - we will have to slowly transition it to modern web standards (apply MVC, use WebAPIs rather than WebMethods (static) on CodeBehind files).
I really am lost. What's the best route in improving a WebForms project to modern standards? Something scalable and cloudable (if that even is a word).
Thanks.
(Let me reach for my flame-retardant underwear.)
The big difference between WebForms and more contemporary web design frameworks is that WebForms attempts to layer an event-driven forms management paradigm on a platform that is not built for events. Web pages are not desktops.
In my experience, the efforts to maintain the illusion of web events in a complex application far outweigh the investment in taking the original functional requirements to MVC, or NodeJS, or React, or some framework that is designed for the calls and responses of the stateless servers of the Web.
I vote do-over. You will have to do your own cost/benefit analysis if you want to take that route. If you do go that way, this forum is a good place to post specific questions with code samples related to coding problems that you uncover on your journey.

asp.net webforms vs mvc which is best for business applications [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 11 years ago.
Diamonds is an ERP based on windows forms, I'm going to redevelop it using web technologies rather than Windows Forms ..
but now I need to decide which is best for this, the ASP.NET webforms (as i think) is easier to (design) i mean here the UI, but the mvc has simpler html output, and some other features ...
can you help me decide which technology to use and why ?
I'm using C#,
Cheers
If you care about extensibility, ease of maintenance, scalability and robustness of your application, as well as development of your software development skills, then stay as far away as possible from web forms.
The whole idea of adding a layer of state by wrapping everything in a form is just wrong. HTTP is stateless, and MVC is built around that model, which is good.
Edit
In regards to the comments made. Web forms applications are not extensible because presentation layer, business logic and data access code (data sources) all reside in code behind. Controls that are offered by web forms are applicable only in web forms. This means that you won't be able to transfer these skills to another web development framework.
Finally, of course it is possible to write a tightly coupled application using MVC - there is always a way to destroy something. There is no argument about that. The main point is that MVC encourages a seperation of concerns and single responsibility principle, when web forms practically takes it away from you.
You have also said that web forms is easier. It's easier if you have been using it and it's faster to pick up in comparison to MVC, however, in a long-term run MVC is likely to become "easier". Watch few videos on www.asp.net/mvc. Additionally you might want to look into test-driven development (unit-testing). I don't think that unit testing works with web forms because everything is so tightly coupled. Please correct me if i'm wrong.
I would be very interested to hear opinions of other developers who have experience of working with both frameworks.
I think both technologies can get a bit complicated after getting past any of the basics. Here are some brief opinions that I gathered while having to implement a project that must live in both MVC and WebForms hosts.
WebForms Positives:
The maturity of the product
Lots of 3rd party support with regard to sophisticated controls
There are ways to get around the legacy-feeling aspects of the framework (e.g., WebForms MVP)
WebForms Negatives:
Page lifecycle issues can anger you to no end; there are a lot of moving parts to a sophisticated web application
Using dependency injection is "difficult" to use/implement
There is a lot in the framework that you can't control
Need something like Reflector to dive into decompiled source when have questions that are not answered by documentation, web, experimentation.
MVC Positives:
Great separation of concerns and support of dependency injection
More control over so many things (i.e., project structure, mvc framework, rendered content, etc)
You can xcopy deploy your app along with the mvc framework on top of an asp.net 4 installation (i.e., to a 3rd party hosting provider)
Native support of JSON
Source code (w/ comments!!) provided so that you can dive into various features when you run into questions on the internals.
They've been doing out-of-band releases on tooling and I believe plan to do so on the framework (?); they have a futures project along with the source that shows you some of the directions they are going and which you could make use of if you should choose to.
MVC Negatives:
Can take a little time to wrap one's mind around
Not as many 3rd party helpers (no controls); those that exist seem to be not as sophisticated as their WebForm counterparts
Personally, I'm an MVC fan because of the control, flexibility, and transparent dependency injection support. Perhaps you should do a small pilot with both technologies to see which one you prefer. Good luck and have fun!
I strongly recommend MVC simply because once the UI is ironed out, it makes development so much easier from a back-end viewpoint. There are TONS of mvc vs asp questions out there:
1,
2,
3
From my perspective MVC wins based solely on TDD and no Viewstate. But it really depends on how you plan to manage and use the various features of either.
I think this post from Scott Guthrie is really interesting to read. After reading, I think you'll most likely go for ASP.NET MVC. :-)
While I have done plenty of projects with web forms, I have to say that the primary reason they exist is to provide a layer of abstraction over HTTP, largely to facilitate an event-based model on a stateless protocol. Unfortunately, like most MS solutions, that comes at a price.
Historically, web forms used to be plagued with issues around the generation of markup. Some of these issues still persist today, especially when it comes to ViewState. Things are slightly better now( you can manage the DOM id in ASP .NET 4.0 ) but web forms will still cause you grief. Common things you'll see in web form projects are vast amounts of biz logic squirreled away in codebehind.
MVC doesn't eliminate this, but it provides a structure and separation of concerns that makes bad practice less likely. That said, although the default view engine is better at producing clean markup from an end-user perspective, the inline code in views is a throwback to classic ASP.
For what it's worth, I've stopped developing web form projects and have moved exclusively to MVC for new work.
IMHO MVC
I had to write a report to justify changing to MVC from Web Forms/Nettiers
I blogged my arguments here
It's all about your choice having Web Forms can give you easy of designing your app where as MVC is now days becoming industry standard and even MS is promoting it a lot. If you want to keep your code clean then no doubt MVC is better choice.

Learning C# prior to learning ASP.NET MVC?

With only mild programming experience in the past, I was wondering about C# and ASP.NET MVC..
Do you guys think it's a better idea to learn C# before learning ASP.NET MVC? I've already delved a little into both of these already, but I still need some help deciding.
I think I would be a much stronger MVC user if I had more knowledge of the C# language itself.
What do you guys think?
Thanks!
If you're going to use C# to code your ASP.NET MVC Models/Controllers/etc. then yes, learn C# before you dive into ASP.NET MVC.
That way, you'll be able to better handle the language issues you're going to run in to when composing your .NET MVC application. Otherwise you're going to be trying to learn two things at the same time and not get a good grasp on either one.
Master C# first, then go to ASP.NET, then learn MVC and other patterns. Don't bite off more than you can chew, newbie mistake.
I agree with your third paragraph with C# at your back you'll be a stronger ASP.NET MVC developer; but I also think that they (C# and ASP.NET MVC) make great co-learning tools. And if you're going to try to pick up both tools, doing it together makes a lot of sense.
ASP.NET MVC is a pretty tough framework to start out on. It assumes you are already versed in ASP.NET, and ideally you even have a little bit of Ruby on Rails or similar experience too (ASP.NET MVC was really influenced by rails). On top of all of that good knowledge of C# is also very helpful.
I guess it depends on what your needs are. Are you going to create a mission critical webapp that your business depends on? In that case, yeah really learn ASP.NET and C# well. If this is just for a hobby and/or learning, then I say just go for it and learn C# as you go.
I jumped into Rails and Django without learning Ruby or Python first.
You learn what you need to know pretty quickly and everything you do learn is always guaranteed to be practical and immediately useful.
If you already understand MVC you already know which piece of code does what.
Knowing C# before jumping into anything .NET related is very recommended if not required. MVC is only a way of making webpages with the tools of ASP.NET which uses C# and VB as its backend languages. MVC is actually called ASP.NET MVC. Think of C# as the equivalent to PHP or Ruby in "Ruby on Rails".
Learn C# first. C# will be around for years to come; MVC may or may not be (Microsoft has a long history of handling web site code with flavor-of-the-month paradigms that don't age particularly well).
I have to disagree with Matt Greer about any assumption for MVC that you are already versed in ASP.NET. Nearly all of the tutorials and/or books that I've come across definitely do not start from an assumed ASP.NET knowledge base. In fact, for a junior developer, I'd think that knowledge of ASP.NET would be detrimental and confusing, as ASP.NET adds a whole bunch of stuff (designers, viewstate, abstractions, etc) that really is sort of the antithesis of ASP.NET MVC development.
ASP.NET MVC, however, is a framework that definitely requires knowledge of C# or VB to implement properly. In the end, any of the code that drives the site will be written in C#. The ability to properly write .net code is a definite requirement.
I'm personally very partial to Apress books, so I'd recommend the following:
Apress Beginning C# 2010:
http://www.apress.com/book/view/9781430231714
I'd also recommend from experience
Apress Pro ASP.NET MVC 2:
http://www.apress.com/book/view/1430228865
Another really great series for learning ASP.NET MVC 2 is the screencast series available from tekpub at:
http://www.tekpub.com.
Asp.net MVC is a framework for web development on top of .net developed in C#.
So if you want to know the priorities(not necessarily in a waterfall model, you can learn them in parallel):
First you must learn C#(some oo priciples and the way you must structure your code).
Second you must learn the rules and techniques
in web development (Html, Css, javascript, Web Architecture and the way it works(concepts like session management, cookies, etc) ...)
and Last learn
the Asp.net MVC

How to write a good core architecture for a project in ASP.NET MVC

I'm going to have to write a big system in January with ASP.NET MVC3 / C#, and need to know how to write a system that will WORK. I do have a bit of experience with ASP.NET MVC and C# but would not call myself an expert. It needs to be extensible so that I can extend it later with new features. How would one go about this? Is there books that explains this topic in detail or should I use trial and error?
In short I need to know good design practice in my code thats extend-able for the future.
Regards
RaVen
The System will be a community portal with forums ratings etc. Cant say more than that << Company Policy>>, The forums I can manage because of plenty open source options... But the rest is up to me.
SOLID == Great Success
Follow SOLID principles in any project and you'll do well.
With regards to core infrastructure/architechure, SharpArchitecture is a good place to start. It is by no means the perfect solution...BUT they give you a good framework to play with and you can have a working system quickly while learning the concepts that work and don't work over time. Take a look and see what you think. It uses NHibernate, Castle and MVC.
Test Driven development will ensure quality for your project. Be strict with yourself, red green refractor. One of MVCs strengths is that it's easier to test.
Professional ASP.NET MVC 2 is a good starting point, though, I would assume that they'll come out with an MVC 3 edition as well. The NerdDinner tutorial contains a lot of ideas on how to structure your application.
Basic advice: work with the MVC architecture, not against it. Understand your application, especially your data model, and layer that onto your application structure. Typically you'll have a controller per model, but not always.
If you want more detailed advice, you'll need to be more specific about your project. I'd suggest coming up with specific questions about various details of your design as you have them, rather than a single question covering the whole project. The latter probably won't get the kind of response you desire.
you can use my "awesome" demo as a start
http://awesome.codeplex.com
If it's going to have to be extensible, make sure you write tests. You'll save yourself sleepless nights in the long run when you fix something, but ended up breaking the entire system.
As far as how to make things "WORK" - that depends on your ability. Read, and look to improve things, but don't get caught in premature optimization or it will leave you dead in the water.
Based upon your edit and your abilities, it might be wiser to select an open source CMS written in ASP.NET MVC and support it. Your skills are good enough, it sounds like, to learn how to write modules and be part of a larger community. You do not sound like you really want to write the whole thing because you are timid about your skills, deadlines, etc. Whilst learning the ins and outs of a well written piece of software, one day you may choose to write your own or contribute to a core piece of the software. There are several to choose from see my comment above under your question.
edit: I also think this will allow you to just start and not worry about every design paradigm people will throw at you for success.
WhoCanHelpMe is a nice reference application. It's built upon S#arp Architecture which is a good starting point for an MVC-application using domain driven design. That will also help you on the way with wiring IoC and db-stuff.
Remember that not every example and framework will fit your requirements, so do as jFar said, think SOLID and make your own decisions based on principals.
You should also look into MEF for extensibility.

What CMS should I learn? .Net ones only

I am thinking of learning a CMS. I am not sure which one will be the best to learn.
I seen quite a few job posting asking for a website with CMS capabilities(so it seems something that would be good to know).
CMS on the surface seem to be easy to use but in my mind this seems to quickly change when I start thinking of sites that need more then just out of the box functionality.
For instance sites that need custom themes. How do you switch out themes with your own layouts? Or what happens if a page on your website needs to have custom logic and cms editing on the same page.
Like say you need to write something that pulls up data from a db and format it on the page but to the right of this data you have a paragraph that an admin should be able to edit through the CMS.
So how do you have this work? How do you add say the gridview server control to this page?
So I guess what I am getting up I looking for a CMS that has good documentation on how to do custom logic on pages and not just a CMS where if your not using there own themes and try to add your custom logic on a page you basically have go through the CMS and change the entire source code.
I like using asp.net mvc but as far as I can really see there is really only one CMS that is built on MVC and that is Orchard but it's still in beta and always changing. So I don't want to invest time to learn on how how to use it and then they make changes and your back to square one.
Thanks
It seems like you have 2 competing concerns: 1) which CMS might be best to learn for "professional" opportunities, and 2) which CMS might be best to learn for staying with relevant/interesting technologies like MVC.
For the first concern, a lot of that depends on how long a particular CMS has been around. For example, DotNetNuke has been around for many year, is well-established, and many use it to build commercial CMS solutions. It is web forms based. There are many other well-established CMS out there. For example, the Web Platform Installer from Microsoft, gives options to install WordPress.
For the second concern, I would recommend Orchard. Yes, it is in beta but it has been in development for a while now and is really getting better stability. Even if there are changes from here, I'd expect them to be minor and not sweeping changes to force to you learn a brand new paradigm. As you pointed out, it is also MVC-based. This let's you do development in a much more friendly way - and without having to jump through a bunch of hoops.
My friend used .Net Nuke to create a CMS.
http://www.dotnetnuke.com/
It was his final project in school and they still use it.
http://www.garneau-tennis.com/
The obvious advantage is that you can develop in .Net.
Check it out if nothing else.
N2 CMS would seem to fit all your requirements:
http://n2cms.com/
http://n2cms.codeplex.com/
I've created two CMS sites recently using this. It is probably the best developed CMS around although there is a learning curve. It also has an ASP.NET MVC version :-)
Several themes come with it out of the box. I have already built two custom themes myself and it was pretty painless.
Dot Net Nuke - Well established and using the MVP pattern to ease WebForms development / testing.
Umbraco - Another well known (ran on asp.net) and they are working on an MVC version.
Orchard - New, very new but all MVC. I think this will be a winner as it matures. It's not necessarily bad to get in early. Even as things change you will be able to pick them up and when Orchard hits the prime time you will already know it while all the others waited for it to get out of beta. :-)

Categories

Resources