Why use ASP.NET MVC 4 over just HttpHandlers with jQuery Ajax?
-
Well, I need to build a small mobile application which will be with one single page only and lots of Ajax calls with jQuery. I love the idea of using a simple HTML 5 page without any page life circle events like Page_Init, Load, etc. It still will be an http://en.wikipedia.org/wiki/ASP.NET page but no form or server controls.I can do all the server work in Ajax, calling http://en.wikipedia.org/wiki/ASP.NET handlers, and it is probably be the faster way. Will it work? Is http://en.wikipedia.org/wiki/ASP.NET MVC a better approach? I did a small thing with simple ASHX (handler) file and simple HTML5 page and jQuery and it works great. So why not do the whole application like that? No need to learn MVC, no Razor, not nothing elseâ¦
-
Answer:
For a simple application you can definitely go ahead and use the handlers approach with classic http://en.wikipedia.org/wiki/ASP.NET. However, if you would like to enhance the application further in the future to cater changing business requirements and the like MVC approach will come in handy. MVC approach basically allows you to organize code better. For example, if you have multiple handlers, and if you wish to impose a security policy or something similar on all the handlers, may be some time later, you will either have to go inherit all the handlers from a base class and make changes there, but if you do it the MVC way such things will become trivial. May be your UI is simpler today, but if you wish to use some business logic in there Razor templates help you a lot. Especially generating complex UI is made very easy with Razor. The bottom line is if you use the ashx approach you will do many things manually, if you use MVC approach your code will be better organized and it will be extensive. So considering the learning curve and future enhancements and the complexity of the application you can decide whether to go with MVC or not.
Amit Hegde at Quora Visit the source
Other answers
Yes , depending on what the purpose of your application is , what the security concerns are if you just use plain HTML , jQuery , ajax etc. You could still use http://ASP.Net MVC with handlers - using handlers only to serve up certain kind of requests like may be access binary files. The solution and structure of the application can be built around http://ASP.NET MVC framework - this gives you a robust architecture if need be . I hope this answers your question.
Madhuri Mittal
Disclaimer: I am author of Entity REST SDK. This SDK creates MVC Controller for easy JSON access as well as it lets you query using simple JSON syntax and it applies security on the fly without coding anything extra. https://entityrestsdk.codeplex.com/ In three steps your server side REST API will be ready, create Entity Framework Model, Apply Security Context for limiting access of data and Create a Routing Rule.
Akash Kava
Related Q & A:
- How can I allow user to create posts in website using ASP.NET?Best solution by Programmers
- How to Undo previous action in asp.net?Best solution by forums.asp.net
- Why is my asp.net menu not showing properly?Best solution by Stack Overflow
- How to use Authorize Attribute in asp.net MVC?Best solution by Stack Overflow
- How to use angular.js with strongly typed view in asp.net-MVC?Best solution by ojdevelops.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.