Declare View
In This Article
Invokes the Visual Studio built-in refactoring that generates an MVC view for the current MVC action.
#Availability
From the context menus or via shortcuts:
- when the edit cursor or caret is on an MVC action declaration, provided that the appropriate view does not exist.
#Example
public ActionResult │TestAction()
{
return View();
}
Public Function │TestAction() As ActionResult
Return View()
End Function
Result:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
TestAction
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>TestAction</h2>
</asp:Content>