Basic guide line for asp.net mvc beginner [closed] - asp.net-mvc

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)

Related

MVC vs. Knockout.js [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I've been using MVC for over a year now, and I like it alot. I've heard of Knockout.js. How is the comparison between these two? Which is better?
MVC seems to have reached its maturity with MVC5, with alot of support.
I do not see knockout.js as well supported. There examples on their site do not even work in Firefox. However, I can see the potential of this since it is written in javascript, client-side, and possibly faster since its client-side, like ajax.
What are the advantages of Model-view-controller vs Model-View-View-Controller?
You should not be comparing Knockout.js to Asp.NET MVC. The only similarities are that they both use the same Model-View-Controller pattern.
Knockout.js:
Knockout is a standalone JavaScript implementation of the Model-View-ViewModel pattern with templates. The underlying principles are therefore:
a clear separation between domain data, view components and data to be displayed
the presence of a clearly defined layer of specialized code to manage the relationships between the view components
The latter leverages the native event management features of the JavaScript language.
Asp.NET MVC:
ASP.NET MVC allows you to build a web application as a composition of three roles: Model, View and Controller.
A model represents the state of a particular aspect of the application. A controller handles interactions and updates the model to reflect a change in state of the application, and then passes information to the view. A view accepts necessary information from the controller and renders a user interface to display that information.
As you can see Knockout.js is an MVC implementation for JavaScript while Asp.Net MVC is an MVC implementation for a complete web application from front end to server. These technologies can even (and very often) be used together to build well structured applications on both the front end and the back end.
You are comparing apples and oranges...
Since you are now familiar with ASP.Net MVC (and the MVC design pattern in general), it is time to take the next step and use a JavaScript MVC framework WITH it.
There are many choices, some popular ones include Knockout.js, AngularJS, Backbone.js, Ember.js, and many more. The site TodoMVC will give you a flavor of what is out there.

Learning Asp.net MVC [closed]

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.

ASP.Net MVC vs Web Forms what are the benefits of one over the other [duplicate]

This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
MVC versus WebForms
Was curious what the main benefits of going MVC over Web Forms. I write everything in web forms currently but I already enforce a pretty strict separation on myself would I see any benefits from moving to MVC?
Currently I use jquery for my AJAX; calling Page Methods and Web Services. I typically only use the Page Load handler to load up my static content. I leverage C# in my Buisness Logic and Data Access layers which my Page Methods and Web Services call. So I am not really using much of what makes Web Forms different from MVC. Also I don't use Session variables.
My only hesitation is that the amount of inline code in the presentation layer feels dirty to me. It is subjective I know but it reminds me a lot of ASP from the limited exposure I have had to it. With how popular it seems to be becoming though I might have reached this conclusion through ignorance.
So the question is what would you consider to be the main benefit of choosing one over the other. Also I primarily write high load database driven web applications. So scalability, speed, and maintainability are my priorities.
Take a look at this blog post on the subject. It does a really good job of covering a variety of advantages to using ASP.NET MVC over Webforms.
Why I love ASP.NET MVC

Should I go for ASP.Net MVC? [closed]

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 12 years ago.
HI,
I want to create an application which requires SQL reports. By SQL Reports I mean using report viewer to show sql reports. I am new to MVC and my idea about MVC is that, dont use Server controls. Should I opt for ASP.Net MVC for this application?
If you mean report viewer, Crystal Reports or Reporting Services - you can use ASP.NET MVC and run reports on ASP.NET page. They can live side by side. In my current project I do just that - all of the application is MVC except for the reports viewer page. This is inside single IIS application - I use local web.config for few tweaks. But you can also dedicate a separate IIS app solely for ASP.NET reporting if you can't/don't want to run ASP.NET reports inside ASP.NET MVC applications.
I also found that sometimes generating reports in ASP.NET MVC as PDF documents and dynamically showing them inside iframe may be a better solution (cleaner and more printer-friendly for users).
From the top of my head. Yes ;)
Although "requires SQL reports" is not a very detailed requirement to go on, can you elaborate what you wish to acheive?
I'm guessing by "requires SQL reports" you suggesting it is very data intensive and you are thinking ORM (e.g. EF) is out of the question.
Weel, you can still use MVC with standard ADO.NET with stored procedures for your data layer. You can even use entity framework with stored procedures if need be.

ASP.NET MVC - How to explain it? [closed]

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/

Resources