Click here to Skip to main content
15,944,390 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Please help me to create an application in mvc with angularjs which supports insert,update and delete.
Note: I don't need web api
Posted
Comments
King Fisher 22-Dec-14 6:22am    
google it
Nityananda Das 22-Dec-14 7:46am    
i already tried but all examples i m getting are in web api...

Ostensibly you can use MVC just like WebAPI, MVC just has more overhead and offers built-in support for nifty things like bundling. MVC also just wants specific function calls rather than using the HttpMethod to route traffic.

This means that you need to call specific functions from your Angular $resource, and that you'll need multiple services to do the job of one angular/webAPI service. Not a big deal, just something that you need to be aware of.

In order to cleanly use MVC (as intended) for SPA applications like this, use the standard model, but return Json instead of views/partials:

C#
public class CrudController
{
    public ActionResult ReadMyEntity(int id)
    {
        var json = dataContext.MyEntities.Where(x => x.Id == id).ToList();
        return Json(json);
    }
}


This will provide a Json array to your Angular endpoint, from which point you can use it just like any other sort of resource.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900