I need to know how to use the asp.net mvc? i am new to this technology and i decided to use it and i have downloaded MVC release 1.0 so i need to know the steps needed fro setup the framework as after setting up the framework do i need to do any configurations in VS? i need a tutorial for creating mvc project and an example with code for accessing database through mvc. and which version or release of mvc u advice me to use release 1 or 2 ?
And with respect to posting back i knew that mvc don't do post back like web forms instead it call controller so is this means that each view (.asox file) don't have a related .cs file or the .cs file is shared with many .aspx files ?
I know that my question is not clear but i got confused from articles about mvc when i ask any question or seatch about mvc many articles without practical example or direct answer to my questions in my mind
Thanks in advance
Asp.net have some good basic tutorials here http://www.asp.net/learn/mvc-videos/ and here http://www.asp.net/mvc/learn/. Hope they help you.
you dont need to do any configuration in VS at all. after you installed ASP.NET MVC you got a new project type called ASP.NET MVC Web Application thats where your journey begins :)
a good place to start would be this little sample app http://www.asp.net/learn/mvc/#MVC_SampleApp
after this you should understand the basic concept of how ASP.NET MVC works
You could start out reading ScottGu's "Nerddinner" tutorial. It was originally published as part of the book titled "Professional ASP.NET MVC 1.0", but has later been released freely on his blog. I believe the tutorial covers all the basics needed to get up and running.
If you feel you need more insight, I would suggest you look to Steven Sanderson's "Pro ASP.NET MVC Framework", rather than the aforementioned book. Sanderson's book seems to cover more detail on how stuff work, and he does a great job trying to promote best practices.
Pick up a good book, e.g.- http://weblogs.asp.net/scottgu/archive/2009/03/10/free-asp-net-mvc-ebook-tutorial.aspx, or go to http://www.asp.net for tutorials.
Related
I just need some guidance. I'm fairly new to MVC3 and to web development in general. I want to create my own project that will involve data storage/access (SQL server db) and user log in functionality. I'm not sure were to start, there seem to be so many ways for this and following tutorials doesn't really give the experience of setting up real life project (or its just my impression). Would you guys suggest starting from an empty MVC3 project, or perhaps use the scaffolding feature and build on top of it and use the membership provider built into it ? Some tutorials (by Scott Hanselman) actually explain how to copy and paste the membership feature into a new project. Is this approach suggested ? Any suggestions will help! Thanks!
Here are some tutorials
MVC 3 with razor
ASP.Net website
MVC Music Store
Strongly typed helpers in mvc
Brad Wilson's Blog
MVC Subdomain routing
MVC Partial Views
Some javascript for MVC
MVC Javascript frameworks
JSON and MVC
Form update using JSON in MVC
I'm just starting too, I found this very helpful, especially the videos on the left.
But what I found extremely helpful is the MVC Music Store and the Contoso University site (I recommend to download as PDF; you can see a button to do so at the top).
The NerdDinner tutorial is a great way to start with ASP.NET MVC, although the online version is slightly out of date. However, I can strongly recommend the book that this tutorial (in its updated version) is the first chapter of: Professional ASP.NET MVC 3.
I always used asp.net webforms with the MVP pattern, it works great for what I need, I basically create a project where all my business rules reside, validation etc... and I then implement my views in the webforms project.
Now we're starting to use asp.net MVC and using the MVP patter doesn't make much sense, right? So what could be a good approach to create a scalable and testable project using MVC that won't make me create my data objects and do validation on the controllers. I don' want to have the same code in different places...
If a web user wants to update his/her profile on the site, there would be some validation rules for when a submit button is pushed, like email address cannot be empty, must be valid and must not exist in the database.
These same rules should be applied if I try to update his profile using the internal admin section without having to duplicate the code there...
If you can point me to a good sample project that deals with this would be great!
Thanks in advance!
You should use the MVC pattern with ASP.Net MVC.
The NerdDinner tutorial is a pretty detailed example for MVC, you can also get a book that includes the tutorial (you might want to wait for the version that covers ASP.Net MVC 3). There are plenty of resources on Microsoft's ASP.Net site.
You can always consult Google.
ASP .NET MVC was built with the Model-View-Controller (MVC) pattern in mind. That would be the pattern you'd want to use.
In addition to the resources magnifico provided, I know others have recommended the some other tutorials. I don't know if these have been updated to the latest version of the framework, but they should still serve as decent beginners.
MVC Storefront series
MVC Music Store
Also the Microsoft Patterns & Practices group recently released Project Silk which gets into more advanced techniques involving a lot of AJAX management of the UI. There's interesting stuff there.
I am looking for best practices for using Razor with MVC 3. Now what I am hoping for is some type of article, not just a list of your professed best practices, but if you have any feel free to post them.
Why is this SO worthy? It seems hard to find info on how to best use Razor with MVC views. I know about the typical MVC best practices, I am looking for Razor specific ones. Those who use Razor know that its more than a token replacer. I want to know more about how you setup the site templates using Razor.
Like I said, I am looking for a good resource on the subject.
have you ever heard of Nerddinner.com? that website has been created with ASP.NET MVC an it is open source on codeplex.
Here is the release that has razor and MVC3 version of it;
http://nerddinner.codeplex.com/SourceControl/changeset/changes/55257
You could download the source code and play with it.
Edit :
Also have a look at below blog posts;
ASP.NET MVC 3: Layouts and Sections with Razor
ASP.NET MVC 3: Implicit and Explicit code nuggets with Razor
Deployment of ASP.Net MVC 3 RC 2 Application on a Shared Hosting Environment Without Begging The Hosting Company
ASP.NET MVC 3: Layouts with Razor
Razor Releated posts on Phil Haacked's Blog
Razor syntax is not all that you are looking for, you want the best patterns and practices with using MVC 3 as well. It is a shame there are Zero books out on MVC3, only web references with vary from small to large degree. At this point you must use stackoverflow and constantly use google and set a date range to search past month or so. Also, setup a google "alert" on mvc 3 razor etc..
I find that pluralsight examples, nerddinner, Silk (MileageStats), MvcMusicStore, ProDinner, and several others to be "useful" yet not one is (or can be) the best practices in every area. Everyone tries the "happy path" but many of the example veer from this. Many examples are doing various IOC containers. Some use Unity others Structuremap, others Ninject. Depending on skill level and existing knowledge, it can be overwhelming.
Personally I'm on a new project with vs 2010 / mvc3 with Oracle 9... Thus MOST of the examples are not terribly helpful as the database integration with EntityFramework use datacontext / IQueryable is great and all, but with Oracle EF in beta, and sprocs not even working with Oracle 9 with EF (per trying , and email responses from Oracle trainers etc..) I end up having to go old school and retrofit ADO.NET and convert to List ... and use IEnumerable. Thus many of the things stubbed out for easy use in the models/controllers/views in the demo projects are half in vain for me with my environment with Oracle.
Well... I use MVC 2 and work and MVC 3 at home and I really haven't found too many differences in terms of best practices for the Razor syntax. I generally just read ScottGu's or Phil Haack's blogs if I want to read about ways to use the features of Razor. Not sure if that helps you any but I am drawing a blank.
Please check below link for example with good presentation.
http://dotnetautor.de/blog/content/binary/Windows-Live-Writer/32ee537b2c00_E16A/MVC3.pdf
I have an existing ASP.NET website with some custom routing, within a Solution that also contains Business Logic projects.
I want to create a new project within the Solution, which is an ASP.NET MVC website.
This website will also call the Business logic, and the ultimate aim is to port most of the code from ASP.NET to ASP.NET MVC.
But I want them to both work side-by-side for now, to ensure minimal down-time, as it's a high-traffic website.
Is it possible to accomplish this somehow using either ASP.NET routing or some kind of IIS setting?
Yep, you just need to add some routing to your current application. Try http://www.packtpub.com/article/mixing-asp.net-webforms-and-asp.net-mvc
Please have a look at this post by Scott HanselMan.
It provides detailed discussion about this along with a nice walk through.
I just wrote a blog post on this. It is possible. You might find it easier to simply relocate your web forms from your existing web forms project to your new MVC project. You may not have to change any code.
I'm struggling to find a good reference application for ASP.NET MVC. By "reference", I specifically mean an application that flexes all of the framework's features in the Microsoft-sanctioned manner, such as:
Master pages
Partial views
Strongly-typed models
Authentication
Custom routes
etc...
The open source examples that are out there (CodeCampServer, SutekiShop) either add significantly to the base framework or don't use all of the baked-in features.
Have you seen Rob Connery's MVC Storefront Webcast Series?
http://www.asp.net/learn/mvc-videos/#MVCStorefrontStarterKit
Source Code:
http://www.codeplex.com/mvcsamples/
I asked more or less the same question here: What are some projects which are examples of best practices for ASP.NET MVC?
As for official, the closest would be Rob Connery's which was mentioned.
This isn't official but you could check out Kigg:
http://www.codeplex.com/Kigg
It's a sizable Asp.net MVC Digg-clone with some decent code in it. Used on dotnetshoutout.com
I would consider the Nerd Dinner MVC reference app: http://nerddinner.codeplex.com/ for people just starting
While this might be a little late to the show, I believe that the ASP.net team would like people to start using the MVC Music Store as the official mvc reference example. The Music Store application is using the Razor view engine with Entity Framework's code first approach (also demonstrates database first) along with examples of dependency injection, test driven development, jQuery integration and getting and using NuGet packages.
A second reference example seems to be more on the cutting edge of things and is provided by the Patterns and Practices people. This is called the Silk Project and takes advantage of the latest web standards like HTML5, CSS3 and ECMAScript 5 along with modern web technologies such as jQuery, Internet Explorer 9, and ASP.NET MVC3.
These together would probably show you the newest in ASP.net MVC development along with some pretty neat ideas and examples.