ASP MVC 3 mobile strategy - asp.net-mvc

I am starting a group uni project and we are using ASP MVC 3. We are going to have a mobile (web) component as well as a "traditional" web app. Some of the views will overlap (as in Incidents mobile view and Incidents ordinary view). ASP MVC 4 has the mobile features that we want, but we don't want to take chances with a Beta version.
What we were thinking of doing was having two MVC 3 projects in our solution, one for the mobile and one for the web app. Alternatively, we were thinking of having some mobile only controllers and having everything in one MVC project. For example (/AccountMobileController/Signup and /AccountController/Signup)?
What do you guys recommend? Is it silly to use ASP MVC 4 Beta?

You can get mobile view support fairly easily in MVC 3. Take a look at how they approached this on Stackoverflow.
http://kevinmontrose.com/2011/07/17/mobile-views-in-asp-net-mvc3/
For the most part, your controllers should be the same for mobile and full site, but the views will be different.

I'd say go for MVC4 Beta.
Although, yes, it is in Beta, it is ALMOST ready for production.
System.Web.Mvc has really not changed that much, and in reality the, "mobile templates" from MVC4 are mostly just Html, Css, and Js templates that come pre-bundled with the templates.
The main new mobile functionality in MVC4 is for swapping out views for different devices.
Plus the Web API is really awesome for creating an API.
http://www.asp.net/mvc/tutorials/mvc-4/aspnet-mvc-4-mobile-features

I'd suggest you to look at frameworks like Bootstrap and Less, they'll help you build responsive websites without too much effort. Just be careful that you do not inject any css or styles from mvc code as it might interfere with them.

Related

Silverlight to ASP.net MVC migration

I am tasked with migrating a Silverlight application to ASP.net MVC5. The challenge is that some of the modules have already been built in an MVC app that can run stand-alone or can load from within the Silverlight application. The existing MVC application has been developed over last 2-3 years by several developers of varying skillsets and the code is not in very good shape. The code has very poor coding standards adherence and poor re-usability, no coded unit tests, no DI, lots of inline styling, etc.
I want to start afresh with a new MVC project for the Silverlight migration so that I can try and address the issues in the current MVC app. Eventually, I want to reach a point where the Silverlight and the old MVC apps can be completely discarded and the new MVC app becomes the only one running. However, until the migration is complete, all three need to coexist. With the Silverlight application, I do not foresee a problem as I can tweak it to load the MVC pages from two different MVC sites. However, the main challenge I am facing is in figuring out a strategy so that users can access the new modules from the new MVC app from the old app until I migrate the old modules to the new app. It would not be feasible to make users access two different web apps for different features.
Some of the possibilities I have explored are,
hosting the new application separately but loading the pages into iframes from the old MVC site.
using something like Razor Generator to precompile the new project and refer it from the old application.
I am not very sure if the above are the best of ideas. I would greatly appreciate any suggestion to help me think and proceed in the right direction. Would also love to hear if there is a better/more appropriate approach to solve this problem.

using ASP.NET MVC and EXT JS together

I'd like to use for my next project Ext js and ASP.NET MVC.
I'm wondering what would be the best way of using this two framework together. So far I did some project using ASP.NET MVC, where every action method returned a view and reloaded the page. The Ext js mvc application uses a single page approach.
As I'm pretty new to ext js so I'm wondering if someone could share some experiences of building real world application using this two frameworks.
You can use extjs as you think is better for you. You can use its components as simple widgets or create a full javascript (extjs) client. However, which are the real requirements? a single page client or a traditional client?
In our current project we started using ASP.Net MVC Framework with extjs widgets, it was ok for a while but the customer wanted more and more sophisticated UI and a better user experince (among other thing) then, we changed the app, we left MVC models and controllers (views were removed) and we created a full javascript client with extjs 4.1.
After that we realized we were using an ASP M_C framework (with no views) and that was a nonsense so, we took the ASP MVC project away and replaced it by a WCF Rest service (it also could be done with an ASP.Net Web Api).
We feel proud of our decision and the resulting design. If you can, if you know extjs (learning it is rather hard) and javascript and, if you have support to your decision then, keep your application splitted in two:
a server-side service/api and,
a full javascript application.
Good luck!
I'm not sure I'd agree with the answer by #lontivero, I'm currently working on a project using ASP.NET MVC as the backend and ExtJS as the front.
You do, as pointed out, loose the V from the ASP.NET MVC stack and you end up needing to duplicate you C# view models in you ExtJS Models on the client side but I've found using MVC as a backend (effectively as a rest based collection of Json end points) absolutely fine.
You can utilise the model binding, model validation in MVC whilst leveraging the full client side js app in Ext.
I'm curious as to the points you didn't get on with using this structure (I'm not saying it's perfect, but it does seem to work)
We used Ext.NET (versions 0.x-1.x) in our previous projects. Even after a comprehensive effort to upgrade our projects to the (now current) version, we had to drop Ext.Net 2.x out.
If it fits you, it can help.
The main problems with Ext.Net were (several) incompatibilities with ASP.NET and a lack of trust. They used to keep their schedule, it's far from it for last 2 years or so. And they are behind ExtJS.

Converting a regular MVC site for use in phonegap

I have a site that's done using ASP.NET MVC and jQuery. Is it possible to modify my existing project without too much of rework so that it can be used in phonegap to create iphone/android apps?
Here's an approach: move your logic to an MVC WebAPI (or other REST/webservice) project, then convert the MVC site into a simple html/javascript/css/image site (Mobile site). Then refactor your Mobile site to use Ajax/JS to query the WebAPI/Rest services you created. Once you've separated your code this way, you can then package the Mobile site with Phonegap. I'm not sure how much work that will be for you or your project. If you're using a lot of Html Helpers or Razor markup in your views it may be too involved.
The core point of my suggestion here is to separate your mobile UI layer and the backend processing layer so you can only package the Html5/UI/Javascript layer with Phonegap and leave the backend processing on your web server. I don't think I need to explain this, but obviously the app packaged with Phonegap is not going to have the MVC/.Net framework available on the mobile device to render views or execute controllers, etc. By migrating your UI to be simple Html5 and Javascript you can use Ajax/Jquery/Javascript calls against your backend, which you will probably want to host in ASP.Net MVC WebAPI.
Edit: Guess there was some confusion about my suggestion. I'm not saying this is the only way to do go, but this is what I'm familiar with as it's how our team builds our desktop/web + mobile + phonegap + mvc4 + webapi + kendoui application. This pattern works well for us so maybe it'll work for you too, or at least give you some ideas on how to structure your solution. Good luck!
I'm not sure but you need a server to compile the ASP.NET right? so I don't think that will work for you. I think you need to work with AJAX to do your ASP.NET work and separate your ASP.NET code and your HTML-jQuery because Phonegap wants a index.html file. You can store your ASP.NET files at a server tough
The answer to your question really depends on the type of site you are trying to convert. Are you just trying to put a native framework around HTML and get your app into an app store?
If it is is mostly or entirely informational in nature and you have simply used MVC to build brochure-ware type pages then it should be fairly easy to move. This assumes that there is little to no logic other than page to page navigation.
If your site instead pushes a lot of data around that relies on a back-end server you will need to re-architect it to store data locally or pre-fetch it via a manifest. Next you will need to implement a strategy that allows you to push your local data back to the server.
Does you app need to run in a disconnected state?
Phonegap is one of the options if you want to target multiple mobile platforms & may be most widely used. Since you are using jQuery, jQueryMobile will be a least learning-curve path to use. Effort is mostly on the front-end UI and will depend on how many screens you want to design to provide a sub-set or the full set of functionality you already have on the web UI. Most likely you will have to redesign your screens using the jquery-mobile UI widgets documented here. It is also a good way to show it to your customer the initial screen design with navigation.
jquery mobile is great for learning and designing , but it's slow in the web browser control that phone gap runs in .
you'll need a more lightweight framework for this .
you can use an inappbrowser control to show your site in case it's responsive , but you wont have the device camera and contacts and so ...
take a look at : http://docs.phonegap.com/en/3.0.0/cordova_inappbrowser_inappbrowser.md.html#InAppBrowser

How to have a mobile version of a MVC website

I currently converted my website from classic asp to ASP.NET MVC, I'll be putting it live in a few days. I'm now thinking that I should start supporting mobile device.
I was wondering if this could be a good idea to do things.
Have the same model
Have the same controller
Have two different view and chose the right one using Request.Browser.IsMobileDevice
One view for mobile display, one view for everything else.
This way I could keep the same URL.
Is this a good way of doing things?
Scott Hanselman blogged about this. He illustrated an example of how you could build a custom view engine which depending on the user agent would render a view situated in a different folder. This way you could have the same Model and Controller but different views.
And this functionality will be built-in out-of-the-box in ASP.NET MVC 4.
For the HTML, CSS, and JS, check out Bootstrap and jQuery Mobile. For Bootstrap, check out this link, scroll down to responsive utility classes and resize your screen.
They are other frameworks out there too that allow you to do similar things as bootstrap as well.

Is ASP.NET MVC a good platform?

I aim to try use DevExpress web server controls (which are awesome) in an ASP.NET MVC project (some articles I read on 'net seems to indicate the two can work well together).
I'm eager to start a new project using ASP.NET MVC, and I have been reading up a lot on ASP.NET MVC lately, but I'm not sure if I should invest a project in it. My concern is that it may turn out to be like LINQ to SQL, which is essentially been killed off since MS will not be providing updates.
Is ASP.NET MVC a viable solution to invest in my case?
Yes definitely ASP.NET MVC or any other MVC framework is worth learning. MVC pattern is all about seperation of concerns and helps you to keep your code clean.
If you like Devexpress control too much you could be disappointed because there is no server side control in ASP.NET MVC. But if you want to learn Web's underlying mechanism,HTML, Javascript , clean code, TDD ASP.NET MVC is a good way to go.
Learn first, experiment later
Asp.net MVC is a great development platform for building web applications, so it's definitely worth your time to learn it through and through.
But I suggest you first learn MVC framework and build at least one semi complex app with it and then start experimenting with mixing MVC with web forms controls. It is possible but as much you think you will gain you'll probably loose more. So I would be a bit reluctant and advise you not to match these. At least not on a Greenfield project.
In other words: presumably knowing Asp.net web forms would you suggest someone to heavy use dynamicly created user controls in their web pages if they're just about to learn the technology of Asp.net web forms? Probably not. Or mixing web forms with ASP pages on a greenfield project...
Instead try finding great either MVC-friendly server extensions or client-side libraries that will help you create rich web apps like ExtJS (I don't work for ExtJS llc, but I used the lib on a project in the past and liked it a lot). Using something like this you won't loose stuff from MVC and gain great user experience and rich functionality.
Seeing how you're asking the question on this site, I'd say YES!
DevExpress has a bunch of MVC specialized controls, that use Ajax to get data from the server via callbacks. You can see demos of the controls here:
http://mvc.devexpress.com.
I am not sure if you can use the web forms controls, my understanding is that you can't.
Also, regarding LinqToSql, you don't have to use that. I am using NHibernate for the data layer and it works very nice with MVC.
I worked with asp.net and web forms for more than 5 years and at least 1 year with the DevExpress controls for asp.net, but now I love MVC so much that I think I don't want to go back to the web forms anytime soon.
Hope this helped.

Resources