It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
I have been working as WinForm (C#) Developer since Aug 2010. Now, I am planning to migrate into Asp.net MVC (C#). I have been learning MVC with http://www.asp.net/mvc for last 10 days. But I found that it only emphasizes on razor technology over ASPX. I just want to clear doubt that Do you use Razor technology in your MVC Project over ASPX. Please also mention other stuff I should learn (or from where) to be an Asp.net MVC Developer (Good & Employed).
Thank you,
Aman
Welcome to StackOverflow (SO)
Razor is simply a template engine, meaning that you write a string and put placeholders in it to be filled by some data. Razor is really easy to use, thus:
hello #name
in Razor would be:
hello <%= name %>
in ASP default inline statements. Thus yeah, many developers recently prefer Razor.
If you want to become a good ASP.NET MVC developer, I suggest to follow these topics as starting point:
Filters
HTML Helpers
Razor Syntax
ViewBag, ViewData, and TempData
Routes
of course, these suggestions need you to know ASP.NET, and MVC, and many more stuff as prerequisites.
Using Razor is indeed a more effective approach then to use ASPX-page markup.
Razor is simpler and cleaner. With "cleanness" comes a better code-walk capabilities. In aspx we had a lot of syntactical junk on the way, and a developer's intention to alter or get to know the code were "wearing off" more quicky.
With Razor, you see a much broader picture of a page's view at a glance.
Razor is not the core of being a good ASP.NET developer though.
The following may be a subjective optinon, but as soon as you realize how web server (ports, urls, routing), Controllers, Views and JSON data fromat tick together, as soon as you are able to quickly parse server-generated JSON model on the client with KnockoutJS or other MVVM framework, making your pages go "alive", you are becoming a developer who can create a web site on his own. You should specialize in something, no doubt, but to be a good developer, you need fully understand how Microsoft Stack of web technologies ticks.
Aman As far as Razor over ASPX concerns, I say yes Razor is widely used in industry and as you are beginner in ASP.NET MVC, I suggest to learn MVC 4. You can get more info on MVC 4 from http://www.asp.net/mvc/mvc4 and here is article series covering new feature in MVC 4 http://www.dotnetexpertguide.com/2011/09/aspnet-mvc-4-article-series.html
I have read 3 books on ASP.NET MVC and 2 books on the Entity Framework. I have been developing in MVC 3 since it was released. Absolutely the best resource I have found is Scott Allen's training courses on ASP.NET MVC 3 on http://pluralsight.com/training/Courses/TableOfContents/aspdotnet-mvc3-intro Scott really knows his stuff.
This isnt just your typical canned developer training that is read from a script by a voice actor. Scott really knows web development and he shares some great inside tips on programming MVC 3. His C# stuff on http://pluralsight.com/training/Courses/TableOfContents/csharp-fundamentals is also very good. No, I do not work for pluralsight, I am just a happy pluralsight.com subscriber.
You must know HTML, CSS, jQuery and JavaScript in order to be an effective and productive MVC 3 developer. Go to http://www.w3schools.com/ and do all of the tutorials on those subjects.
Related
i have been lately read some articles about BreezeJS. But till now i can't get my head around it.
What exactly BreezeJS is used for in details with examples not just words?
Can i use it in asp.net WebForms(most of tutorials target MVC projects), and if so how can i use it ?
Is there any concerns i need to take in consideration before i use it ?
I'm going to break your first question into two pieces:
Do you want to build a JavaScript / Single Page Application?
If you want a cross-platform application with a more fluid user experience, or have a need for offline operation, then Single Page Applications may be a good fit for you.
Why should I use Breeze in a Single Page Application? Can you cite examples?
John Papa has a great post about this that includes a few examples:
http://www.johnpapa.net/spajs04
You can use WebForms, MVC, or any number of other technologies to build a Single Page Application. For ASP.NET, people typically use MVC4 though. Here is StackOverflow post on that topic that might help:
webforms vs asp.net mvc for single page application - which to choose?
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Still i am not familiar with asp.net mvc. Now asp.net mvc is very popular. Before learning it I like to know few things like:
If there is no concept of viewstate then, how control state is maintain during postback? If discuss it in details and if possible give me sample code for persisting control state in mvc.
In webform we often use update panel and other controls of ajax control toolkit. So tell me how people embed ajax functionality in mvc? One option is jquery, but is there any other option too? Is there anything like update panel or ajax enabled controls?
You said it is possible to work with asp.net webform and mvc in same project. So tell me, how data can be pass to webform or aspx file?
How very easily we can migrate any asp.net webform project to mvc?
Is there any easy small project based on mvc, which beginner can dowload and go through the code, to understand flow of mvc project? Just like any shopping cart.
What is strongly type & partial view in mvc?
I have no idea about mvc project type. That is why many question is coming to my mind. Please do not feel irritate to answer all this. I apologize for all the above basic question.
This is borderline subjective and might be closed but I will give it a go at my responses to your questions.
The web, by nature, is stateless. ViewState and Postback are .NET concepts that are not natural to the HTTP protocol. If you absolutely must keep persistence, you will need to look at cookies/session.
You can use a framework (jquery and jquery UI, YUI, etc) or roll your own javascript functions. The concept of web controls (though they 'could' be used in MVC) is gone. You will use standard input, select, button HTML controls.
I have not done this, I cannot provide much help here
Depends on the project and how it was written/coded. There is no straightforward 'conversion' that one can do. MVC vs WebForms are two different paradigms.
MVC Music Store and MVC NerdDinner
Strongly typed views are views that are passed a class (model) that has a specific set of properties defined. Using this model, you can pass only the data you need for that view, do type checking when posting back a form, etc. A partial view is simply a view that does not contain all of the layout (master page) stuff. It is to be used to simply display a subsection of a web page (think of a panel)
I've heard that the approaching umbraco 5 i going to be based on asp.net MVC. Does it mean that the developers will have to be familiar with the MVC? Will you please tell me what the exact meaning of being "based on MVC"?
Umbraco 5 has been cancelled. Fortunately, a small team of developers has decided to fork the project:
http://www.rebelcms.com/
It means exactly what it says: Umbraco 5 will be an ASP.NET MVC3 application instead of being a webforms application.
This indeed means that your developers will soon need to be familiar with MVC, although, it is quite feasable that most of the Razor concepts are already known to your developers.
If you have more specific questions, don't hesitate to post them. A better area would be http://our.umbraco.org though, the community is quite large and much more responsive there than on Stack Overflow.
This is very intesting stuff about Umbraco 5, as I know Sitecore, for example, should include support of MVC as well. But they will support both variants for developers ASP.NET and ASP MVC. That from my point of view much better. May be Umbraco 5 will be have the same
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
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 9 years ago.
Improve this question
I am trying to teach ASP.NET MVC to students (undergrads) that have been studying ASP.NET for the last 8 weeks (I know that doesn't sound like much time, but the class is 4 hours per day, 5 days per week with Labs, Quizzes, Exams, and Wrestles).
I haven't gotten the question yet...but I know it is coming...
When would I use MVC instead of ASP??
I don't have any real experience with ASP MVC and I can't find any sort of clear-cut answer on the web. Arguments such as "...the web is stateless and ASP MVC is a closer match etc etc" do not mean much to them. They are starting to notice that ASP has lots of controls that seem to simplify their markup compared to MVC.
I'm trying to give an honest spin, and any feedback would be much appreciated!
TIA
Statelessness is a good one word to explain as already highlighted by the members.
Apart from this ask the following questions to the students?
If they have to do the following with ASP.NET (no MVC), how easy will it be?
Test your views
Mock Http objects.
Viewstate reduction (by design)(
Substitute lightweight viewengine for .aspx.
Thorough separation of concerns.
Clean HTML
etc. etc..
Now explain asp.net mvc in the above context. There may be more to it.
Atleast I think they will get the point, thought this may not be applicable to all project, but what's the harm if we are only gaining from this.
To me, the MVC approach is a very different paradigm from the ASP Forms API. I think the idea of being "stateless" is a good way to explain a very broad topic in one word actually.
One of the major advantages that I've seen is that the MVC framework gives a lot of control over the design and the output of your page. For small projects, this may not be the best use of it, but for large projects, it scales very well because you can make different architectural choices that (personally) I find to be better, such as the way that the MVC framework separates logic from the view.
Also, if you're designing a site that has a lot of Javascript, the control you gain over output in the MVC framework can be very helpful because you don't have to worry so much about how IDs and other markup may be rendered, like you typically do in the ASP Forms framework.
The MVC framework is really a totally different way to design web sites. Personally, I think it is more beneficial for large projects, but I also started out in web languages where MVC was a more popular design choice to begin with.
That's just my 2 cents.
I always thought the ASP.NET MVC Framework was a bad name since its a Design Pattern.
The question should be :
When would I use ASP.NET MVC Framework over ASP.NET Web forms?
The Developer Experience
a) ASP.NET Web Forms tries to abstract away the stateless nature of HTTP from the developer. The state of GUI Elements, and or data is stored in the Viewstate/Session. Everyone Form does a postback to itself, basically mimicking the behavior of a WinForm event driven design.
b) HTML GUI Elements are further abstracted by Controls which can be re-used, bought from 3rd party vendors. This helps developers glue an HTML app together without to much JavaScript and HTML/HTTP Knowledge. Basically similar to the way you would develop VB / WinForms
c) You can do a good job implementing the MVC/MVP pattern in ASP.NET webforms. Look at the Patterns and Practices Web Client software factory to see how they did it.
d) Developing using WebForms you are generally changing the HTML (View) based on user feedback at the server. Most events (user clicks a button, edits a field) are handled at the server in a continuous postback loop executing whats called the ASP.NET Page Lifecycle.
VS
Browser controlled view (dont know what else to call it). All changes to the HTML based on user input is handled in the browser. You will be manipulating the DOM with Javascript.
Note: I basing this on the fact that ASP.NET MVC is most likely driven by basic HTML + Ajax
How I would personally choose between them (never having used MVC, just reading on it)
1) If I was to build a pure stateless front end using Ajax, Jquery, EXT JS type libraries ASP.NET MVC would seem the better fit. Although you could build this in ASP.NET Webforms it seems pointless since you not taking advantage of the Postback model and Server Controls.
2) If I were asked to build a new basic web application, I would stick with ASP.NET Webforms since i'm already familiar with it and know the whole page lifecylce.
3) If I were asked to build a Web 2.0 (hate that term) to have a next gen User Experience, I would probably go with ASP.NET MVC, and use JQuery / ASP.NET Ajax client controls.
4) Many companies have built up a solid set of WebForm controls to use. It would be costly to rebuild them all in a pure stateless ajaxy way :)
For someone with experience (and pains) in Winforms - the biggest difference is no more Viewstate. The state of controls on the form is kept on the client, in the browser and sent to the server for each request.
If you use Javascript, it is easier to make changes on the browser side, while the server side gets an easy way to look at the form as a whole without having to recreate controls binding.
Beyond all the nice things MVC provides - separation of view/code, testability - this was for me the key point to move to MVC.
Apart from all the other excellent responses already listed. Webforms is an abstraction away from HTML.
When you want a html table of data, you put a "gridview" control on a page - what you end up with is "gridview" html, and quite possibly not exactly what you were after.
The shoe fits 90% of the time, but a lot of the time, especially when things move beyond a basic site that the controls don't fit. Using Webforms often means that you don't have full control over the final output that is rendered to the browser.
You can of course extend, or write your own grid control. But wouldn't you just prefer to write the html you want instead?
It's my experience that has the projects get more complex, and UI's get more complicated that you end up fighting webforms more and more often.
http://www.emadibrahim.com/2008/09/07/deciding-between-aspnet-mvc-and-webforms/