I want to create an application which i want to work both on web and windows for which i want to make seperate presentation layer. first of all i want to know, Is MVC is only for web applications?
By all means no. Check out this quote from http://blog.iandavis.com/2008/12/09/what-are-the-benefits-of-mvc/
The Model/View/Controller (MVC) triad of classes [first described by
Krasner and Pope in 1988] is used to build user interfaces in
Smalltalk-80.
When I was in graduate school we used MVC for Java apps...
Not necessarily only for web, depends on how you use it. It's just a framework that should work on both. Example, iOS development is also done on MVC style. But if you're using WPF/Silverlight, you should look at MVVM rather than MVC.
As far as i know MVC gives you more command over building the html. User MVC if you want a clean and more controlled html output. if you are developing a business application set-up a a solution and DAL and other business logics layers in class library type projects and then build separate user interfaces for both web and desktop. ASP.NET will be best if you don't want more control over output HTML.
Related
With the latest release of ASP.NET CORE version 2.0 we now have Razor Pages which I really like because it shows a MVVM way of developing which I am already familiar because I've used it in UWP.
I was searching to develop web apps without js because I am a .net developer and I came across this framework known as DOTVVM , it is great because it gives some features of js frameworks like Angular, React etc. and it also integrates very well with ASP.NET CORE 2.0
I want to discuss this between following 3 scenarios :
I should use DOTVVM and not use JS at all.
I should use Razor pages instead with asp.net core 2.0, because razor pages provide all functionality which dotvvm provides and it will have more community in future.
I should learn a JS framework like Angular or React because neither razor pages, nor dotvvm is powerful enough to replace them.
The discussion can be from point of view of all developers, so I can get opinion of JS developers as well as those who have worked with dotvvm or Razor pages. The aim is to create completely interactive and responsive web app with good performance.
**Important : ** the web app created can be a progressive web app from the start or maybe turned into a pwa after creating it, depends on the technology I choose at the end.
I know for a progressive web app I will need to write a little JS, but that is alright considering that is very simple and little to write.
The reason of this question is so that we can discuss these options from multiple perspectives and deduce a better option at the end for my app.
It really depends on the type of the application you are trying to create. The fact is that you can build any application in any web technology. The difference is only in how difficult it would be.
Razor Pages are very easy to use and they are part of ASP.NET Core platform. They are using the MVVM pattern, but they are not helping with client interactivity. If you need to hide some form field based on some condition, you would need to do it in JavaScript.
I would use them for a simple company website, very simple admin sites with few pages and trivial forms, or for a public facing part of some eCommerce site. I would probably use also jQuery or other libraries to do the interactivity, animations and things like that.
DotVVM is an MVVM framework which helps especially with web applications with complicated UI: lots of complex forms with dozens of fields and interactivity (when you select an item in a combobox, another combobox will get new values, some fields will be pre-filled, a part of the form will disappear or change and so on). Modal dialogs, multi-step wizards, lots of grids with data, sorting, paging...
Because DotVVM handles many things for you and translates the data-bindings to JavaScript, you don't need to write the JS yourself. It doesn't mean that you should not learn it. It will help you a lot if you know it - you will be able to add even more interactivity, extend the framework when you need it and more. DotVVM lets you do quite a lot without knowing JS, but you will get much further if you know it.
Angular, React or other client-side frameworks are used widely today and many websites and applications are built in that. They are more universal than DotVVM, which aims primarily at the business app segment and requires .NET on the server (because it is not only the client-side library).
Using Angular or React requires the knowledge of JavaScript, and not only that. You will need to know Node.js and the related tooling, like npm. You will need to exchange data with the server, so you will need to build probably a REST API, use Swagger to generate the client-side proxy classes, and then you will probably need some other JS libraries with controls and things like that.
It is quite a lot of things to learn and if you are used to the comfort of Visual Studio, like the IntelliSense or the debugger, you will miss these features for sure.
And finally, you don't need to stick to one technology. You can combine Razor Pages with DotVVM for example. You can make the admin dashboard in DotVVM and the public part of the website in Razor Pages.
Microsoft is coming back to the WebForms approach to simplify the project structure trusting in the "Convention over configuration" mantra, while hiding the configuration from developer to make things faster. But it has the disavantage that everything will be mixed again. I doesn't look like a smart move for organizing. But... Hey! Something new must catch the attention of the dev towards Microsoft.
If your page uses an MVC Web API for the REStful, it's really more easy to just use Razor pages. If not, I would recommend you to use Core MVC.
Bit of a beginner question, but I'm currently building an ASP.NET MVC web app and I would like to transfer my models and data across to a Windows Universal App to begin with and then maybe a Xamarin app in the future.
Are there any good tutorials or blog posts out there that anyone can recommend that would help me. The idea is that the user will have the same experience across web and mobile so I don't want to hard code models for each client.
To do this you will need to split your domain model into different projects.
When you create your MVC application create a new C#/VB.NET assembly and place all of your models in the assembly. This way you can reuse the code across multiple projects.
Keep in mind that you shouldn't just dump code into this assembly take the time and create a proper namespace structure so that you don't confuse yourself or anyone else later on down the road.
I want to make available the UI for my site administrator to upload the advertisements for the site. I just come across the Google adsence concept for the same. so can i build this using adsence API and how ? I mean i need the sample P O C so that move a head with considerations. i am new in adsence totally. i didn't heard about it so far. so want to understand its capabilities also.
Considering you have multiple pages to display the same data, so potentially different Views, you can take into account MVP / MVC patterns. So main purpose is to separate View from undelying logic and data itself.
Also take a look at the ASP.NET MVC, perhaps you can build your web application using this framework.
ASP.NET MVC gives you a powerful, patterns-based way to build dynamic
websites that enables a clean separation of concerns and that gives
you full control over markup for enjoyable, agile development. ASP.NET
MVC includes many features that enable fast, TDD-friendly development
for creating sophisticated applications that use the latest web
standards
I'm developing an ASP.NET MVC 3 website that can manage my budget and expenses. It's almost done. So, I have my models, my views, repositories and controllers, and these two last have some important logic, about how to find and return searches and about business logic. OK, so far so good.
But, I'd like to develop and Windows Phone 7 App where I want to make avaiable some part of the features the site will offer, so I could use the exact same controller action that the ASP.NET MVC 3 site have, but I don't have a clue about how to do it.
I never worked with WP7 development, I know it is Silverlight-based, I know a little WPF and Silverlight, but I don't know how to glue my business logic that already exist in my controllers and repositories with the app. I know I can consume Web Services with Silverlight, but then I would have duplicated logic, in my actions and services? How I can handle this? Is there any resources that can help me through this learning process?
What I want, actually, is a way to reuse everything I already have, without duplicating the logic, or, at least, make only small adjustments.
Thanks for the help and sorry if my english isn't clear enough.
Try watching the video series The Full Stack on Channel 9. In the series they build an MVC site with a WP7 companion app.
http://channel9.msdn.com/Series/The-Full-Stack/The-Full-Stack-Part-1-Building-the-Admin-Site-with-ASPNET-MVC-3-NuPack-and-EF-Code-First
You should not program your business logic into your controller. Controllers are part of the user interface and setup the data for the views which are purely web based.
Therefore you cannot reuse your controllers in Silverlight, but you could use your business logic and implement a service interface for the Silverlight application which runs in the browser. If you used Entity Framework you could use the wcf services.
Before you start thinking about Silverlight you should learn XAML and WPF, then Silverlight and last but not least WP7 (which is mainly SL3 based plus some phone specific add-ons).
The other option you have: you use your web application and use the html interface on your phone 7 the same as on your webbrowser. The next release of phone 7 os supports html 5 as well.
I have built and application in ASP.NET MVC, which started out orignally as a way to learn the technology. However, the application (and my knowledge of MVC) have progressed and I would like to use parts of the functionality I have created in other applications. Eg I would have 2 websites both wanting to use the same News Control (CRUD) model and controller methods, but with their own unique Views. I suppose my questions are:
1. Is this going against the principles of MVC?
2. What is the best way to achieve this?
3. Is there a "best practise" way to re-use my exisiting functionality?
Thanks in advance for any answers.
Depending on your exact requirements I'd recommend you take a look at Rob Ashton's series on multi-tenancy in ASP.Net MVC, and also the portable areas part of MVC Contrib.
You could setup a Visual Studio solution in which you would have a common class library project containing models, controllers and data access and two web applications containing only the views and CSS of the two sites both referencing the same controllers and models.
Hopefully most of your logic is already separated out, but you can also pull your controllers out to a separate assembly, I believe:
http://dotnetslackers.com/articles/aspnet/storing-asp-net-mvc-controllers-views-in-separate-assemblies.aspx
Reuse is a really central part to the concept of MVC. It's very common in production MVC sites to have a separate assembly (or assemblies) for the Model. It's somewhat less common (but still done) to do the same for Controllers. The S#harp architecture project (for example) uses a separate assembly for everything, leaving just views, content, and global.asax in the Web assembly. It's all good.
Another thing you might consider is the use of Areas, which are like mini-MVC apps that you can reference in your 'main' app. It's a great way to package reusable pieces like you describe.
Paul