You need to resolve the error so that the new view is displayed when the Index method is invoked

You create an ASP.NET MVC 2 Web application that contains the following controller class.
Public Class ProductController
Inherits System.Web.Mvc.Controller
Shared products As List(Of Product) = New List(Of Product)()
Function Index() As ActionResult
Return View()
End Function
End Class
In the Views folder of your application, you add a view page named Index.aspx that includes the
following @ Page directive.
<%@ Page Inherits=”System.Web.Mvc.ViewPage” %>
You test the application with a browser. You receive the following error message when the Index
method is invoked: # The view ‘Index’ or its master was not found.# You need to resolve the error so
that the new view is displayed when the Index method is invoked. What should you do?

You create an ASP.NET MVC 2 Web application that contains the following controller class.
Public Class ProductController
Inherits System.Web.Mvc.Controller
Shared products As List(Of Product) = New List(Of Product)()
Function Index() As ActionResult
Return View()
End Function
End Class
In the Views folder of your application, you add a view page named Index.aspx that includes the
following @ Page directive.
<%@ Page Inherits=”System.Web.Mvc.ViewPage” %>
You test the application with a browser. You receive the following error message when the Index
method is invoked: # The view ‘Index’ or its master was not found.# You need to resolve the error so
that the new view is displayed when the Index method is invoked. What should you do?

A.
Change the name of the Index.aspx file to Product.aspx.

B.
Create a folder named Product inside the Views folder. Move Index.aspx to the Product folder.

C.
Replace the @ Page directive in Index.aspx with the following value.
<%@ Page Inherits=”System.Web.Mvc.ViewPage(Product)” %>

D.
Modify the Index method by changing its signature to the following
Function Index(ByVal p As Product) As ActionResult



Leave a Reply 0

Your email address will not be published. Required fields are marked *