locked
Adding MVC's to a pure Web.api-project RRS feed

  • Question

  • User1222158709 posted

    I have an existing web.api-project to which i need to add some controllers/views/models from a MVC5-project to reuse an administration backend. The web-api project is very clean and i'd like to keep it that way not adding tons of mvc stuff. The mvc's should if possible live there own seperate life inside the project and not even use the web-api controllers or models. Side by side you know.

    I tried to achieve this by hand not using template or anything, by adding bits and pieces of folders, references, controllers/views/model-classes and config-stuff here and there in the project. Clearly i was not successfull because when i try to view my cshtml-files the server just returns server errors. Now i wanna start over in more structured manner...so my question is:

    With a pure web.api-project at hand, how can i add just basic mvc-support?

    Saturday, May 9, 2015 12:47 PM

Answers

  • User1644755831 posted

    Hello mcskelle,

    For supporting MVC in pure web-api you will need to add following reference to the project.

    MVC

    • System.Web.Mvc.dll
    • System.Web.Optimization.dll
    • System.Web.Providers.dll
    • Newtonsoft.Json.dll

    Razor View Engine

    • System.Web.Razor.dll
    • WebGrease.dll
    • Antlr3.Runtime.dll

    http://www.hanselman.com/blog/IntegratingASPNETMVC3IntoExistingUpgradedASPNET4WebFormsApplications.aspx

    this article is for adding mvc to web forms but you can get general idea what kind of dlls MVC requires in order for to work.

    Hope this helps.

    With Regards,

    Krunal Parekh

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 11, 2015 4:40 AM