I am new in Asp.Net MVC and has been assigned a project. I have created a view named as "webMaster.cshtml" in Views/Shared folder. My controller name is: "EmployeeController" and Action name is: "ViewEmployees".
public class EmployeeController : Controller
{
//
// GET: /Employee/
public ActionResult ViewEmployees()
{
return View("webMaster.cshtml");
}
}
View Page
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>@ViewBag.Title - Practice MVC</title>
</head>
<body>
<h2>webMaster</h2>
</body>
</html>
Error while running the project
Server Error in '/' Application.
The view 'webMaster.cshtml' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Employee/webMaster.cshtml.aspx
~/Views/Employee/webMaster.cshtml.ascx
~/Views/Shared/webMaster.cshtml.aspx
~/Views/Shared/webMaster.cshtml.ascx
~/Views/Employee/webMaster.cshtml.cshtml
~/Views/Employee/webMaster.cshtml.vbhtml
~/Views/Shared/webMaster.cshtml.cshtml
~/Views/Shared/webMaster.cshtml.vbhtml
Now, my question is why it is searching for: "~/Views/Shared/webMaster.cshtml.cshtml" Instead, it should search for "~/Views/Shared/webMaster.cshtml"
Please help in sorting this out.
Thanks.
MVC will take your string and look for it in a whole whack of places like you can see in the error message. As such, it doesn't want you to dictate the extension.
Change it to:
public ActionResult ViewEmployees()
{
return View("webMaster");
}
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments