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?
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>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.