Skip to main content

Can declare MVC view

In This Article

CodeRush Classic shows the Can declare MVC view code issue if an MVC action includes a reference to an undeclared MVC view.

#Fix

Declare an MVC view for the undeclared reference.

#Purpose

Shows all MVC actions that do not have corresponding views.

#Example

public ActionResult TestAction()
{
    return View();
}

Fix:

<%@ 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>