Click here to Skip to main content
15,905,614 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
I am creating a music store application using the tutorial from the link and here the problem is that when i just added a new view its shows the error
Server Error in '/' Application.
 
The view 'Contact' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/Home/Contact.aspx
~/Views/Home/Contact.ascx
~/Views/Shared/Contact.aspx
~/Views/Shared/Contact.ascx
~/Views/Home/Contact.cshtml
~/Views/Home/Contact.vbhtml
~/Views/Shared/Contact.cshtml
~/Views/Shared/Contact.vbhtml


Controller Code

C#
public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewBag.Message = "Welcome to ASP.NET MVC!";
 
            return View();
        }
 
        public ActionResult About()
        {
            return View();
        }
 
        public ActionResult Contact()
        {
            ViewBag.Message = "This is our contact page";
            return View();
        }
 
Layout.cshtml
 
<quote:ul id="menu" xmlns:quote="#unknown">
                    @Html.ActionLink("Home", "Index", "Home")
                    @Html.ActionLink("About", "About", "Home")
                    @Html.ActionLink("Contact", "Contact", "Home")
                >

View Folder Structure

views
Home
ContactUs.cshtml
Posted
Updated 6-Nov-13 7:59am
v4
Comments
abbaspirmoradi 6-Nov-13 13:55pm    
Are you create Contact view into correct folder?

For other instances of this error, return View("logon") does not work for me. I have found out that return RedirectToAction("View", "Controller") does solve this issue.
 
Share this answer
 
There you have it: ContactUs.cshtml. Why do you think, that the engine will guess this?
Either rename it to Contact.cshtml or return with the proper view: return View("ContactUs");. See: http://msdn.microsoft.com/en-us/library/dd460352(v=vs.108).aspx[^]
 
Share this answer
 
Comments
Member 10370658 6-Nov-13 23:22pm    
ohhh Thank You :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900