Microsoft mvc3 or ASP.NET Web pages for a new server-side scripter? - asp.net

I have experience in javascript, html(Bronze certified), css(Gold certified), sql and xml(Bronze certified), and now have turned my attention towards server side scripting. I have little experience in php but have no Idea what to choose between MVC and ASP.NET Web Pages. I like all the features that ASP.NET Web Pages(Since I already new a little about server side scripting, so getting started was not that difficult and I know a few basic things.) have like, automatic form authentication among others but I seriously doubt that it can never be by-passed. Still, for safety I use my own algorithms against sql-injection and javascript codes. But, now I am confused what to learn, MVC or ASP.NET Web Pages. All the posts I searched on internet where for new programmers. Since I am not new they are no use to me. So what should I learn MVC OR ASP.NET Web Pages and why?
*English is not my native language, there may be some grammatical mistakes.

You are kind of asking what's the better option, apples or bananas. MVC is a pattern and allows you greater control over what HTML is sent to the browser whereas Web Forms has a great number of pre-made controls that do all the hard work rendering out html to the browser (but often less control of how it is rendered out)
It's also down to preferences, I personally prefer MVC as the unit testing and component nature of it give me great flexibility. Alternatively, using WebForms you can create some things quickly using drag and drop controls.
Hope that gives you a bit of useful info. I'd recommend reading up about both, and seeing which fits into your style of programming and go from there, but there's nothing stopping you learning and using both (just don't use them in the same project, lol)

Related

Is there a reason that cshtml isn't popular

Firstly, I have only recently tried my hand at building with razor in cshtml using Webmatrix and I found it much less time consuming than building aspx web forms. Having gotten used to it, I can now do all the things I used to do inside my aspx projects much quicker and with much less code...
Now, I've spent today looking around google etc at companies using cshtml, what they're using it for etc, but I can't find a large range of examples out there. Maybe I was just looking in the wrong place, rendering this question title incorrect, but I just had a feeling that there is a reason why companies are still using aspx over cshtml.
I'm about to start a project next month for a big client and I can't decide whether to take the step of building it this way (they need a custom blog, login area etc). Any thoughts? The only other stack thread I found of any use with regards to a debate was: Razor/CSHTML - Any Benefit over what we have?
Thanks,
Adam
A lot of it has to do with ASP (classic) has been around a lot longer and (depending the project size) a migration can incur too much cost.
There's also considerations like:
What does the current web staff know (what are they fluent in?)
What libraries (proprietary or otherwise) are already dependent on ASP (including custom controls).
How much of an SEO hit are you going to take converting (some sites can mimic classic aspx page suffixes by just changing the way the routes behaving but are in-fact using cshtml).
There isn't a compelling reason for experienced ASP.NET developers to move from Web Forms or MVC to Web Pages (Razor). As a framework, it is designed to attract those who might find Web Forms or MVC too much of a learning curve. Those coming from Classic ASP or PHP, for example.
I answer a lot of questions on the Web Pages framework over at the ASP.NET forums, and I have definitely seen an increase in the number of people trying the framework out. In terms of functionality and security, you have the whole ASP.NET framework behind you so you can do anything with Web Pages that you can do with MVC or Web Forms - a lot of it more easily.
The Web Pages framework is not designed with testability in mind, and it may be more difficult for teams to organise since a certain amount of server-logic is embedded in the same file as HTML.
If you are a lone developer and happy using Web Pages, go for it.
There been a lot of discussion about the topic. Its just opinions, right tool for the right job. Please look into the following for opinions & answers:
MVC 3 ASPX VS RAZOR View Engine
Razor vs Webforms view engine for new ASP.NET MVC 3 site
What is the difference between Razor and ASPX?
Hope this helps

Does ASP.NET MVC provide a more suitable solution to being browser agnostic as opposed to Webforms?

Hopefully this question is not to confusing, but I can help clear it up and there is a definitive answer: Yes or No (and why of course). I develop a lot of internal intranet applications using ASP.NET Webforms targeted for the Windows Environment and IE. This allows things like Windows Authentication and the drag-and-drop ASP.NET server controls work extreamly well and the focus is typically on the function rather than the pazzaz or the look of the site; I'm not selling products here to the masses.
However some users are starting to use Macs, and as we know the default browser is Safari. Unfortunantly Safari does not support Windows Authentication. To add on, a lot of the out-of-the box ASP.NET server controls don't render properly as they do in IE. Plus I have to take into account all the differences I need in my .js as well.
Now looking at this from an internal busniess perspective, having a single enterprise platform is not uncommon, so assuming the users are on IE is not a problem. However as more Macs get introduced, bridging the gap to make these intranet web apps browser agnostic can be quite a difference in development time.
I was wondering if ASP.NET MVC has a leg up on this issue. I know it does not solve the Windows Authentican issue (chime in on this as well for solutions), but I was wondering since server controls were not being used like with web forms, if using MVC was the advantageous choice when trying to make web applications cross browser compatible? I don't mind doing MVC as opposed to webforms, and if there is documented or gained knowledge on why MVC works better for cross browser use, then speak to it. If experience shows the way that MVC renders its controls as opposed to server controls from webforms is better across different browsers, this is mainly what I am trying to detmine.
Does anyone know about this? Thanks!
ASP.NET MVC gives you more control about how HTML, CSS, and JavaScript is rendered because you don't have all of the built-in controls that render this for you. Since you have full control over these elements, you are more enabled for developing in a cross-browser manner. This puts more burden on developers. It's a classic power vs. responsibility trade off.
MVC does do away with the mangled html of server controls, the huge footprint of viewstate, and generally makes the rendered html much cleaner and more efficient. So to answer your question, Yes, MVC will make it easier for you to have clean html that stays just the way you wrote it, without having asp.net's rendering mangle everything.
Windows authentication is supported in Safari. If you are facing issues can you give some specifics.
The web form controls (with newer version of asp.net) usually work across browsers fine. The problem is when it doesn't, it is hard to track them down. I have also had issues where they didn't work well with IE6, tracking them and fixing them is little hard in Web Forms. But that is trade off if you want drag and drop controls.
With MVC, there is no concept of controls similar to web forms. You control everything that is delivered to the client, the HTML, CSS and Javascript files. You do have HTML helpers to render your models to corresponding HTML controls. The amount of extra code you will be writing will depend on the task you are trying to accomplish. Since you control all the assets delivered to the client it makes it easier to track bizarre one off browser specific issues.
Using MVC doesn't mean you won't run into cross browser issues, you will. It may be easier to fix but then if you are experienced in web forms you should be able to achieve the same results.

Silverlight or ASP.NET or both?

At the moment I am starting to learn Silverlight. I have expriences in ASP.NET and like the concepts of "Masterpages. Does Silverlight provides a similar concept ? I have read a little bit about the Silverlight Navigation Framework. Is this a good replacement for "Masterpages" ?
Makes it sense to combine ASP.NET and HTML (with Javascript) with Silverlight or is it more recommandable to design and write pure Silverlight applications ? Mybe in the ner future I will start to develop an intranet (business) application which will have many and complex user interaction (it should behave like a windows client applicion). I think Silverlight is the better choice than ASP.NET !? Makes it sense also to start to use/learn the WCF RIA Services immediatly ?
Are there good (VS) templates to start with Silverlight or which are a good basis / starting point for a new Silverlight application ? Unfortunately I am missing "Starter kits" on http://www.silverlight.net like the starter kits on www.asp.net !
Thanks in advance for your hints.
Silverlight and ASP.Net are light years apart technology wise, Silverlight is closer to Winforms programming than it is to ASP.net, event though it can be hosted inside an ASP.Net page.
To achieve "masterpage" type functionality, you can have a base control or page that you can inherit everything else from. Or you can have a page which acts as a shell and you can swap views in and out depending on the user's actions.
If you are writing an app from scratch, you can do the whole thing in silverlight. You can navigate from one silverlight control (hosted in an aspx page) to another aspx page (with silverlight controls in it), but there is a performance overhead when transitioning between aspx pages (they are web pages and need to be served). You should look to eliminate separate aspx pages if possible, and create it as one big silverlight application - if your application's functionality is all rolled into one application (not spread amongst aspx pages) then you can make the most of Silverlight's Out Of Browser feature.
However you should only consider silverlight if you are build web apps or interactive/streaming stuff. If your pages are going to be largely static (i.e. presenting product catalogs, or a site where the user just drills through from one page to another) then using silverlight would be overkill, you would be better off sticking with ASP.Net or ASP.Net MVC.
Masterpages does Silverlight provide a similar concept ?
Not directly but it does provide a variety of ways to acheive the goals of Masterpages. The navigation framework is mostly the sort of thing you would need to achieve the typical reason to use Masterpages.
However its also possible to achieve "masterpage" functionality more generally by creating a UserControl that has ContentControl instances at points where in ASP.NET masterpages you would have used a asp:contentplaceholder. These content controls would be bound to custom properties added to the UserControl. This completed UserControl can then be used as the "LayoutRoot" of another UserControl or Page. Note this does not require inheritence from the "master".
Does a combined ASP.NET and Silverlight app make sense?
Well thats a tricky one the answer really is, "It depends". There are way to many factors to give this a true answer. Factors:-
Is this a public app or an internal app?
How important are including rich UI features?
First time Silverlight dev will cost you, is your project able to absorbe that?
What client platforms do you need to support?
How might ASP.NET-MVC + appropriate use of JQuery size up against your requirements?
Probably others I haven't thought of yet
Is Silverlight is the better choice than ASP.NET when there are many and complex user interactions?
The phrase "complex user interactions" could mean a couple of things? Do mean complex to deliver with HTML and Javascript but simple for the user? Or is this a sophisticated app aimed at an expert user?
In either case its likely that Silverlight will start to come into its own here.
Does make it sense also to start to use/learn the WCF RIA Services immediately?
Yet again the answer depends of the type of application you have in mind. If its line of business app where data is searched, edited and reported on then (assuming you have decided to develop in Silverlight at all) definitely you should be looking at WCF RIA Services as well as the parts of PRISM that think are appropriate.
Other types of apps may not benefit from WCF RIA Services.
Are there good (VS) templates to start with Silverlight or which are a good basis / starting point for a new Silverlight application ?
There are no start kits at present. However I think you will find what you need amoung the various demos and tutorials on the silverlight learning site.
I've particular found the videos useful. If you decide to go Silverlight its well worth clearing a day or two to got through the relevent ones.
These are a lot of questions at once.
Yes, the Navigation Framework functionality is pretty much equivalent to the Master Pages concept. Even to the point that it is tracked in the URL when users navigate, so they can use the back and forward button of their browsers.
If you want to do a stand-alone Silverlight application or a hybrid pretty much depends on your requirements and on the type of application you want to develop. If it's a Line of Business application, you might be doing fine with Silverlight alone.
For a public, content/text-intensive website probably HTML with some silverlight gadgetry here and there might still be preferable.

Best mechanism to have rich form controls on web page (HTML) equivalent to windows forms

I am working towards porting a windows application to web. The windows application is quite rich w.r.t. the form controls, complex validations and user interactivity.
Basic web forms are inadequate to meet these complexities. So I would like to know the best way to still have the richness on the web pages. I have some ideas and would like comments.
Use DHTML & Java Script to mimic complex controls. There are some macro controls available as part of jQueryUI that can be used and some other third party Java Script controls. I'd like suggestions if there is a recommended control library.
Use RIA (preferably Silverlight) wherever rich controls are needed. I'd like to keep this as a last option because it mandates the Silverlight plug-in.
What are other popular / preferred strategies?
If you don't mind a departure from .NET "controls", I'd try Ext JS. It is dual licensed GPL/Commercial so you'll likely have to pay for it, but the components are more robust than Telerik or the other .NET versions.
I would suggest that you also check out the tools from DevExpress (http://www.devexpress.com). I've used both Telerik and DevExpress and ended up going with just the DevExpress tools. Both companies, however, are top-notch and both have tools that can really enhance your UI.
With that being said, I would strongly suggest that you avoid the temptation to just port your fat client UI to the Web. That is, if you are just looking for web controls to take the place of your current Windows controls but otherwise leave the UI intact, you are likely to be disappointed. The web is a different kind of animal and people expect to use it differently. With Ajax, JQuery and the various specialty tools from a company like DevExpress or Telerik you can do amazing things on the web that are the equal of anything you may have done in your current fat client interface but they will be done differently.
Reasons for this advice? First, in my experience Windows UIs migrated to the web feel clumsy and inappropriate. The controls aren't the only thing that changes - the entire windowing and content flow models are different.
Second, if you are deploying to organizations outside of your own, you are likely to find that there is significant resistance to using any kind of plug-in - including Silverlight. We win business all the time because we've stayed pure web.
Third, to the extent that you try to build web apps while not really learning web development ethics and methods, you'll just slow down your eventual evolution to true web development experts.
Anyway - that's my $0.02.
We have had a lot of success with the Telerik controls for ASP.NET.
http://www.telerik.com/products/aspnet-ajax.aspx
They also have a suite of Silverlight controls.
http://www.telerik.com/products/silverlight.aspx
And for ASP.NET MVC.
http://www.telerik.com/products/aspnet-mvc.aspx
They are very easy to use and richly featured. The demos on their site should give you a good feel for the capabilities.
There was an article on Codeproject which covered converting Winforms to ASP.NET
Hope this helps.

Has ASP.NET MVC made Web Forms a Legacy Platform?

Last week at Mix '09, the final version of ASP.NET MVC 1.0 was released.
Some of the stated benefits of this framework are:
Clear separation of concerns
Testability - support for Test-Driven Development
Fine-grained control over HTML and JavaScript
Intuitive URLs
Now, Microsoft are being careful to tout this as being "an alternative, not a replacement, for ASP.NET Web Forms", but given the advantages mentioned above, I'm wondering:
How long will it be until "classic" ASP.NET Web Forms is considered to be a "legacy" framework?
If you were kicking off the development of a new .NET web project today, why would you choose to use Web Forms instead of the ASP.NET MVC offering?
Good questions. I think ultimately, the answer is going to be the development team's expertise and the project needs that will decide that. ASP.NET web forms is so heavily used that it likely isn't going away anytime soon. Plus, there are so many custom controls and third-party support such as components and books. The main benefit of web forms is how easy it is to get a dynamic website up and going. It really is a RAD way of developing websites.
However, once that team has more experience with creating larger websites with much higher demands in terms of scalability, reliability, and test-ability, then they will look towards other solutions for that. In this case, they will realize that web forms are harder for unit-testing. They may also see that viewstates reduce performance and look for possible solutions.
Although MVC has the stated benefits, it is unlikely that anyone will convert their sites to use this new framework right away or ever. Plus, it requires the team to learn the new technology, and work out the new bugs. The team will have to learn new ways to do the exact same thing. For example, how easy is it to support uploading a file using MVC?
As I saw recently, there isn't a reason you can't create a site using MVC and web forms together. So you may see more hybrids in the near future. But I doubt that web forms will ever go away.
I kind of think about web forms like the way VB1 changed the way Windows applications are created on the desktop. To this day, the RAD way of creating application still exists and will never go away.
Keep in mind that MVC STILL uses WebForms for it's default View Engine. Sure, you can replace it with another one, but WebForms is still a core part of it.
Also, not everyone prefers to tightly control the HTML or the Routing. That's not my attitude, but some people just want their job done with the smallest effort.
And aren't .asmx Files technically part of the "old" Model as well? I can say for sure that a lot of people would not like to see them go away.
Still, I personally see ASP.net MVC becoming the main Web Engine for ASP.net in the future, although not in .net 4.0 yet.
You're asking when a newly-released web platform, ASP.NET MVC, will replace Web Forms, which has been around for seven years.
If we'd been crying out for ASP.NET MVC for the past seven years, then it wouldn't have taken seven years before ASP.NET MVC was released. The fact is, not everyone sees a need for this. Many of us have been creating complex, highly-scalable web applications for most of those seven years.
We even knew how to make them testable, and to separate presentation from business logic and data access. ASP.NET MVC may enforce this separation, but I've done it by using coding standards and code reviews, and by saying, "there's no unit test for that", and "get that business logic out of the UI".
Also, if I really needed more control of the HTML, I would write my own control to generate the HTML.
I do not believe WebForms will ever retire.
I've been using WebForms at work in business applications and MVC at home for some private things. Though I really like MVC I do not see how this could be possible to implement really complex UI logic with HTML/CSS/JavaScript. It will quickly become unmanageable and will be quite unsecure since JavaScript can be switched off to prevent disabling some controls or hiding some information. On the contrary, turning off JavaScript with WebForms will virtually turn the page dead for any action, either authorized or not.
Both platforms will continue to evolve. For general web sites and HTML/CSS lovers MVC is a way to go, with complex applications you would want object-oriented architecture and artificial event handling even though it abstracts you from the stateless nature of HTTP.
So, pick up what is best for you.
P.S. Dropping WebForms altogether will jeopardize the future of numerous projects and companies throughout the world. Microsoft folks would not want to become an object of hatred and the trigger that started the third world war.
WebForms will still have a place for those that want a pseudo-stateless web application that they can easily put together by dragging and dropping. For those that don't have to or want to understand how HTTP works. It's the ultimate in RAD for web applications.
ASP.NET MVC on the other hands allows much more finer control at the cost of more responsibility. You get complete control over your HTML however that means you have to sanitize/encode your output yourself. Your application for the most part has to be completely stateless and for some ASP.NET WebForms/Windows WinForms developers that it's a bit hard to wrap their mind around.
I don't think either will ever dominate the other though one may be favored.

Resources