views:

188

answers:

4
+3  Q: 

MVC View Problem

Hi,

I have an mvc application running on IIS 7.0 on windows vista.The appication is redirecting to the proper controller and action.But i am getting an error saying view is not found in the path, when the view is present at the particular path.

Route is as shown below.

routes.MapRoute( "Default", // Route name

"home/{action}/{id}", // URL with parameters

new { controller = "Home", action = "Index", id = "" } // Parameter constraints );

I am getting the error as The view 'Index' could not be located at these paths: ~/Views/Home/Index.aspx, ~/Views/Home/Index.ascx, ~/Views/Shared/Index.aspx, ~/Views/Shared/Index.ascx when i run the mvc application http://localhost/mvcsf/Home/

A: 

The choice of view is defined by the controller. What does the home controller do for the Index action? If this is the vanilla site generated by the system, then it is expecting to find "~/Views/Home/Index.aspx", via the controller's action (below). So: does this index page exist?

    public ActionResult Index()
    {
        ViewData["Title"] = "Home Page";
        ViewData["Message"] = "Welcome to ASP.NET MVC!";

        return View();
    }

(the default view has the pattern {controller}/{action}; you can specify other views via overloads on View(...))

Marc Gravell
A: 

Yes the action is exactly the same and the index.aspx page exists in the virtual path "~/Views/Home/Index.aspx". If I create a new view and change in the controller action still i am getting the error as view not found.

AvidProgrammer
A: 

Try something like this, it seems like it lies in the Windows features that comes with IIS 7 :

http://blogs.dovetailsoftware.com/blogs/kmiller/archive/2008/10/07/deploying-an-asp-net-mvc-web-application-to-iis7.aspx

TStamper
A: 

I had to reconfigure IIS to handle MVC apps. Check this one out as well:

MVC Config on IIS v6.0

Boydski