Have anybody compared ASP.NET MVC to CodeIgniter? - asp.net-mvc

Is there a lot of similarities? I can webforms ASP.NET and some CodeIgniter but haven't much grokked with the asp.net mvc. Have they a lot of similarities?

Other than being frameworks build around MVC there aren't many similarities. (ie they both have folders for Models/Controllers/Views and automatically wire things for you based on naming conventions)
CodeIgniter is the most basic implementation of MVC possible, which allows for incredible flexibility when building your app.
ASP.NET MVC has alot built into it, and is strongly typed. LINQ to SQL provides a built in ORM and the basic MVC templates have frameworks for authentication built in utilizing ASP.NET Membership provider model.
Views in MVC are typed as well, so you have to define the model being passed into the view as opposed to CI which you can pass anything basically.
The helper classes are completely different as well.
ASP.MVC is built upon ASP.NET so alot of things will seem similar with Webforms, but you need to understand MVC pattern. Check out the NerdDinner tutorial for a fantastic introduction to ASP.MVC. (which is a Wrox book which they now make available for free online)
http://www.asp.net/mvc/learn/

Related

Net5 razor pages vs mvc

I am new to net5 framework and have some questions regarding the structure of the project.
When we create a new project it will only create the razor pages. I am learning that we can achieve things with these razor pages.
Meanwhile, I have looked into some open source net5 projects on GitHub and see that they are also using MVC.
So, my question is why do we need MVC then? If everything is achieved using razor pages then what is the need for MVC?
If we need MVC then should we use razor pages with them too?
I have done the identity work with razor pages using scaffolding. What would happen now if I add MVC to my project. How will I manage the routes and page redirection from razor pages to MVC and vice versa?
Please help me with this so I can clear my concepts on this.
I will be really thankful to those who explain the scenario to me.
Thanks
First, .NET 5 is out of support. You should target .NET 6 instead.
Razor Pages represents a simpler way to generate HTML on the server compared to MVC. It is recommended for all new web applications that rely on server-side HTML generation going forward. MVC is still available for existing apps. It is also probably easier to migrate older MVC 5 (.NET Framework) apps to ASP.NET Core MVC when porting to .NET Core.
Razor Pages is built on top of the MVC framework and depends on a lot of the features of MVC such as model binding, action results and so on.
If you are using Razor Pages, there is no compelling reason to also use MVC in the same project, although you can. If you do, then you need to register controller endpoints:
app.MapControllers();
You might need to add controllers to your project if you want to create HTTP service APIs, although you can use the minimal API feature that was added to .NET 6 instead:
https://www.mikesdotnetting.com/article/358/using-minimal-apis-in-asp-net-core-razor-pages
Razor Pages can make coding page-focused scenarios easier and more
productive than using controllers and views.
https://learn.microsoft.com/en-us/aspnet/core/razor-pages/?view=aspnetcore-6.0&tabs=visual-studio
As another difference, in MVC, you usually create separate class for ViewModel. As I understand, in Razor Page, you don't need a separate class and you just add more properties in the same page and those properties will be part of your model which make things easier.

.net mvc book for a rails developer

I am a rails developer and I am looking for a good .Net MVC book or tutorial. I don't know where to start. Do I have to learn .Net web forms and c# first, or can I go directly through .Net MVC?
You don't necessarily have to start with Web Form; being a Rails developer, it might even be easier for you to start with ASP.NET MVC. Ultimately, each offers a very different approach to web development and your choice will depend on your specific needs. Many will argue that MVC is the better choice.. realistically, each has its place. Moreover, keep in mind that not every ASP.NET MVC web application will be built from scratch; several projects will probably end up migrating from classic ASP.NET.
C# is one of many programming languages available for use in .NET....and although I strongly suggest learning C#, you could -technically speaking- use an implementation of Ruby called 'IronRuby' to get started. Should you first learn C#? Again, it's up to you... though just as it is helpful for a Rails developer to be proficient in Ruby, being comfortable with whichever language language you choose will prove helpful in learning a new framework. More importantly, the learning curve will seem much steeper if yo try to tackle both at the same time.. C#, can certainly differ from Ruby.
Anyhow, I highly recommend PluralSight & Microsoft's Virtual Academy to get started.
As user3435091 says, you don't need to learn WebForms, that is the old school way to do web applications in ASP.NET (the book detailed below explains why, but basically it has to be with actually web apps tend to be stateless and webforms goes to the opposite direction). With ASP.NET MVC, you will find a fundamental similarity to rails, you have Models, Views and Controllers as you would expect (they both follows MVC which is an architecture), so you don't have to change the way you think today about building a web applications. The template engine MVC uses is Razor which also uses the concepts of views, partial views, layouts, helpers, helpers for ajax, etc (it uses jQuery by default too).
The hardest part to learn I think would be with ORM (you have EntityFramework and NHibernate, the .NET implementation of Java Hibernate :s ) and that C# uses attributes (similar to java annotations). Also, you are not provided with the nice rails console out of the box in .NET.
The book I used to learn ASP.NET MVC 3 (and which I can recommend) is Pro ASP.NET MVC 3 by Adam Freeman and Steven Sanderson.
Hope that helps.

ASP.Net MVC or Web forms which is better

I am going to start work on a SaaS based application. I need to decide whether to go with ASP.Net MVC or web forms application. Through various posts I came to know that both are good, they are not replacement of each other and so on.
Also, I know traditional web forms method, I am not aware of MVC, I need to learn it first.
Please guide me which approach is better.
Thanks,
Vijay
i can just share some of my experience as i have worked on both
i preffer asp.net MVC over Asp.net because of the futile layer of abstraction that Asp.Net has over basic HTTP architecture
the user controls in asp.Net induce unnecessary markup
ease of using ajax in asp.net mvc compared to updatepanel(in advanced senarious)
support of razor type syntax increases productivity
no overloading by things like viewstate
because everything is managed by the programmer soem of the typical issues that arise in asp.net like the problems in dynamic controls are no longer present
so if you ask me go for asp.net MVC
There is no right answer here. I prefer MVC but if you already know ASP.Net WebForms it probably is easier to stick with that.

Migrating a webfrom asp.net appllication to MVC

I have been working on a CMS project based on asp.net webforms. It follows simple multitier architecture and contains a single aspx page where the usercontrols (ascx) in the form of modules are loaded dynamically.
Now a lot of clients are demanding it in MVC. I m wondering if it is feasible to seamlessly convert it into MVC. Is the hype just because MVC is the new paradigm for dot not or is it because it does yield substantial benefits?
What is the easiest way to migrate from WebForms to MVC?
You can always convert your existing ASP.NET web application project to include MVC and make it as a hybrid application. Scott Hanselman wrote a simple post to demonstrate how to do that.
If you are trying to add MVC to existing ASP.NET web application, Check out this link. I have scribbled a useful tip there to bring the MVC specific Context menu ( Add Controller/Add View) in the solution explorer.
The below statement is purely personal. (of course both has it's own pros and cons)
Personally If i start a new project, i will choose MVC over webforms. because i tasted it. It is addictive. :) I think My MVC projects are much cleaner than webforms ones.

What is ASP.NET MVC not good for?

I'm a big fan of what ASP.NET MVC is doing, on many levels.
I'm about to take part in re-build of a very highly trafficked website, and I'm not which framework would be best (if any).
The site will need the following:
To support Javascript-heavy, highly interactive pages
But at the same time, provide underlying semantic HTML for search engines
Support multiple languages
Be skinnable
Expose a RESTful web-service API for partners
As far as I can tell, there's no reason not to use ASP.NET MVC for this.
I can present semantic HTML and layer Javascript on top using jQuery.
Multiple languages can be catered for using Resource files (same as at present).
Skinning can be done with CSS (it won't involve changes to the markup).
I can centralize business logic so that the Controllers and the WCF web-service use the same code.
But are there potential drawbacks to using MVC that I haven't considered?
I don't want to be the guy who picks a technology because it's cool but finds later down the track that it isn't very suitable for the job.
ASP.NET MVC is not good when all your doing is making a website that needs server-side code (but that's also true about ASP.NET also).
In your case I think MVC would be a great way to go. MVC has proven itself on high traffic websites (e.g. this one). However you must remember that MVC is new and changing. A library may not exists to do a specific task which means you'll have to write that code yourself.
Good luck on your rebuild!
You're good to go with MVC given what you've said about your project.
As far as I'm concerned, ASP.NET MVC is really only NOT good for situations where you have a large codebase in WebForms (meaning you have a lot of ASP.NET user controls, custom controls, etc). It's also not good if you are going to have people working on it who don't know what it's all about. Other than that, it's a pretty nice technology.
My two cents:
ASP.NET MVC is a great option but there is a little learning curve involved, so make sure your project plan/timeline has this handled. There might be developers on your team who might not be comfortable working with ASP.NET MVC, and this can cause possible delays (a lot of developers are still working in ASP.NET 1.1!).
#Alex: Lack of controls. Some features (like TreeView or Menu) are already implemented as Controls and it would be waste of time to reimplement them using mvc.
IMO the idea of using controls in ASP.NET MVC doesnt make much sense. You can create a treeview control using jQuery easily. Classic ASP.NET server controls carried a lot of baggage (viewstate etc) and hence ASP.NET MVC did not use any of those controls (though you can use helpers).
Finally, ASP.NET MVC is an alternative, not a replacement to Web Forms. I would not use ASP.NET MVC as it is still evolving, and my team is not very comfortable with it, but I guess slowly more and more programmers would shift to this (better) option.
I do not like ASP.NET MVC because of following reasons:
1.
Ugly routing API, there http://ayende.com/Blog/archive/2008/11/05/a-case-study-of-bad-api-design-asp.net-mvc-routing.aspx
is description of what is wrong.
By the way, friendly urls can be easily implemented without mvc
http://demo.liveui.net/bugtracker/Tasks/7
2.
Poor object model. It is proved that good software should consist of reusable components. There is nothing that can be reused in ASP.NET MVC based web site. For example, if you implemented smart drop down list once it will be difficult to use it again (even on the same web site).
3.
Lack of controls. Some features (like TreeView or Menu) are already implemented as Controls and it would be waste of time to reimplement them using mvc.
If I were you I would try to find some CMS and customize it for WebSite needs.
To responses:
YES. I know about ASP.NET controls disadvantages, but the question is about ASP.NET MVC. One can write a book about what is good and what is bad in ASP.NET but I do not think it is appropriate to discuss it here.
There are better ways of implementing MVC without using asp.net MVC. I have done it in the past, even before asp.net MVC came live. MVC is a pattern, not a technology, I do not understand why some people call it a Technology. You can separate all concerns by removing the code-behind from webforms and create your own controllers and routers and you will still have the advantage of the webform controls, etc to which most asp.net developers are used to use. asp.net mvc is nice for people whom do not really have the time to properly create an MVC app in a webforms environment and also to those whom do not have the time to architect a better solution. in conlcusion, asp.net mvc is good but there is a much better way of doing it and finally, MVC is NOT a technology.

Resources