This project is read-only.

~Index.cshtml could not be found (WebAPI 2)

Mar 7, 2014 at 12:39 AM
Hi guys,

I've got a scenario where I have created a MVC 5.1 web application that needs to be consumed by an ASP.Net Web API 2.

When I run the MVC application using RazorGenerator it works beautifully however when my WebAPI 2 consumes the DLL the views no longer work however all the json requests to return the same content as the view in json works.

What do I need to do for my MVC application with precompiled views to work in ASP.Net WEB API 2?
Mar 7, 2014 at 1:15 AM
Not sure I understand how RG relates to WebAPI here. WebAPI normally doesn't have anything to do with Razor.
Mar 7, 2014 at 2:37 AM
Well I've got a scenario where my MVC app which has precompiled views using RazorGenerator but the precompiled razor viewengine is not behaving the same in WebAPI 2.
Mar 7, 2014 at 3:12 AM
Edited Mar 7, 2014 at 3:14 AM
Task : Serve MVC Views from Web API 2 application

1.) I have precompiled the MVC views using RazorGenerator in an MVC application.
2.) I've referenced the MVC application in an Web API 2 application.
3.) I hit the relevant URLS and get *.cshtml is not found
Mar 7, 2014 at 5:00 AM

There was something wrong with my WebAPI 2 project.

I created a new WebAPI 2 project and added the MVC assembly with precompiled views and it worked like a charm.
Mar 7, 2014 at 5:35 AM
Great, glad you got it working!