Reputation: 4947
I'm trying to come to grips with the new ASP.NET Core 1.0 which states that both ASP.NET Web API and ASP.NET MVC are combined into one framework. So I decided to create a new ASP.NET Core Web API application using the ASP.NET Web API template from Visual Studio 2015.
But when I looked at the generated files/folders, there is no Views folder. The ValuesController is generated. I even added my own Controller which returns Web API responses. But I should also be able to add actions in my controller that returns, say, partial views as well right?
Since these two were merged, I assume I should be able to see a Views folder but I don't. How do I add the MVC parts to an app that was created using the Web Api template?
Upvotes: 3
Views: 1526
Reputation: 3867
You can add a Views
folder manually by following these steps:
Views
folder._ViewStart.cshtml
in the Views
folder with this content:@{
Layout = "_Layout";
}
Shared
folder inside the Views
folder._Layout.cshtml
inside the Shared
folder with this content:<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - Web App</title>
</head>
<body>
@RenderBody()
</body>
</html>
Upvotes: 5