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

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.

Related

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

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)

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.

Convert existing asp.net application (large) to web standards

I have a very large ASP.NET project that i need to make good with web standards -- the application has two parts:
1.) An administrative piece that allows users to 'build' sites
2.) Front end that makes up the users sites (many web controls, master pages, usercontrols, etc... much of it is just code)
I was wondering what poeples recomendations are for making this project utilize web standards? Should i look more into MVC? I havent done anything with MVC but it seems to support friendly URL's by default.
Has anyone done this with an existing large ASP.NET application/site?
thanks in advance :-)
What do you mean by web standards? Valid html/css? no-tale layout? valid javascript?
I suggest you just test it in different browsers and fix the problems you find.
There are two routes you can take.
1) Rip it up and start again
2) Modify what you have and incrementally change it 'one page at a time'
I know that's a simple and obvious answer but truthfully, having done both, they are both viable.
A modern ASP.NET web applciation CAN be standards compliant, can have nice urls with some url re-writing and can seperate content from design. You just need to think before you act, make sure you use .NET 2.0 or .NET 3.5 controls and inspect the output to ensure you're getting good markup.
Converting an old web app to MVC can;'t really be answered without knowing the app itself. It might be perfectly suited to it and be easy, it might be a world of pain.
As always use the best tool for the job.

Using Silverlight for an entire website?

We need to build an administration portal website to support our client/server application. Since we're a .Net shop the obvious traditional way would be to do that in ASP.Net. But Silverlight 2 will be coming out of beta a good while before our release date. Should we consider building the whole website in silverlight instead, with a supporting WCF backend?
The main function of the portal will be: users, groups and permissions configuration; user profile settings configuration; file upload and download for files needed to support the application.
I think the main reason for taking this approach would be that we have good experience with WPF and WCF, but little experience in ASP.Net. Either way we would have to learn ASP.Net or Silverlight, and learning Silverlight seems a more natural extension of our current skills.
Are there any big no-nos from the experience of StackOverflowers? What are the big positives?
I would recommend against building a pure Silverlight site.
Silverlight suffers from the same issues as Flash does: Unintuitive Bookmarking, issues with printing, accessibility issues, not working back buttons and so on.
Also, you would require your users to have Silverlight installed or at least to have the ability to install it.
In controlled environements (eg. in large companies or health care) or on mobile devices, this might not be the case.
I would definitely go for a full Silverlight application, specially if you have good experience from WPF. You will be able to reuse your knowledge from WPF, and should be able to pick up Silverlight fairly quickly. I've been working with Silverlight since Beta 1, and the current Beta 2 is of solid quality. I guess it's safe to assume that a RTW version is just around the corner.
Pilf has some valid point, specially around printing. For that I would probably use SQL Reporting Services, or some other reporting framework, on the server side, and then pop up a new window with printable reports. For linking and bookmarking the issues are no different than any other AJAX application. I did a blog post today about how to provide deep linking and back-forward navigation in Silverlight.
Silverlight also has all the hooks needed for great accessibility support, as the UI Automation API from WPF is brought into Silverlight. I don't know if the screen reader vendors have caught up yet. The styling/template support in Silverlight makes it easy to provide high-contrast skins for visual impaired users if that is a concern.
Depends on your goals. If administration portal is part of application and will only be used from computers where your application is installed, there are plenty of advantages of going fully Silverlight - or even WPF.
But if you can see a scenario where it will be used either from random PC or by random person, fully functional HTML/Javascript version is absolutely necessary.
Some reasons are:
Most people don't have silverlight and you'll earn a good load of swearing if they have to download and install it. Some people who have it installed keep it disabled (together with flash and sometimes even images) to avoid distractions and speed up browsing.
When HTML site fails, user gets error page and reloads. When silverlight fails, it can hang or crash.
HTML is what is expected - both by users and web browsers: back and refresh buttons work as they should, hyperlinks and forms work as expected.
Slow internet is still very common, both in remote areas and mobile devices.
I agree with what everyone had said so far and I think this Flow Chart, which is aimed at Flash, also applies to Silverlight.
Source of Image
It sounds like your problem is that you need a rich-client admin application. Why not use click-once?
On the topic of remote andministrators, another poster stated that was an argument in favor of HTML if the admins were on a slow connection. I would argue that depending on the type of information, it may be more efficient to use Silverlight. If you have an ASP.NET datagrid populated with server side data binding, you can be downloading a ton of markup and viewstate data. Even if you're using an alrternative to DataGrid that's lighter on the ViewState, you will still have a lot of HTML to download.
In Silverlight, once you get the XAP down, which is probably going to be smaller than the corresponding HTML, the XAP is cached and so you shouldn't have that cost every time, and you'll just be retrieving the data itself.
For another example, let's say you have a bunch of dropdown lists on one of your forms which all have the same values in the list. In Silverlight, you can get these values once and bind them to all of the dorpdowns, in HTML you will have to repeat them each time.
This will get better with client side data binding in ASP.NET, which follows a very similar model to Silverlight and WPF for data binding.
Overall, I would also think that you would need to write less code for the Silverlight implementation which can increase productivity and reduce maintenace costs.
ASP all the way. You should only use silverlight/flash etc when text can't do what you want it to do - e.g. display video.
Using a plugin for your website makes it slow, and requires the user to have the plugin installed. Silverlight for instance rules out all Linux user. Also, since Silverlight is pretty new, there is no telling how committed Microsoft will be to keep the platform alive if it doesn't pick up soon.
I'd stick to plain old HTML with server side scripting.
Also, for public websites: Flash and Silverlight can't be indexed by any search engine, so good luck with writing tons of metadata if you want any visitors at all.
Silverlight is a good choice for an internal-facing portal, just as it would be for a public-facing portal if you've already evaluated your project and have decided to go forward with a web portal. You are free to integrate Silverlight components within an existing ASP.NET application (i.e. the "islands of richness") approach, but if you have the ability to build a new project from scratch, don't discount a completely Silverlight solution as a valid choice where you would have went with a traditional ASP.NET portal. Silverlight is RTW now, so if this decision is still on the table, you know you won't have to deal with breaking changes going forward.
There are some downsides with developing a site completely in Flash / Silverlight, but if those downsides won't matter to you or won't have an impact then there is nothing stopping you. Choose whatever tool you think meets your needs more fully. I wouldn't be put off creating a site purely in Silverlight based on the downsides, because it brings a lot more positives to the user experience.
The previous comments have dealt with most of the downsides of using Silverlight for a site like this and I agree. If you're determined to have rich-client style development and your audience is small (for admins only) then I'd probably recommend WPF over Silverlight as it currently provides a richer set of tools and controls.
If you stick with ASP.NET have you looked at Dynamic Data - it's ideal for building backend management sites with little effort.
I've seen "Silverlight only" websites at Microsoft and they are pretty impressive. But again, the demos were there to exploit the full potential of what Silverlight can do. The moment you need something different you may be out of luck. I don't see Silverlight like Flash except in the way they are installed/seen. But the Flash/ActionScript backend is really bad compared to what Visual Studio can offer with .NET
Ask yourself why would you like to use Silverlight? Fancy effects or programming model?

Resources