2

I'm hit a problem when attempting to deploy a MVC app as a sub-application of an existing ASP.NET 3.5 app (non MVC). The error is:

The view 'index' or its master could not be found. The following locations were searched:
~/Views/employment/index.aspx
~/Views/employment/index.ascx
~/Views/Shared/index.aspx
~/Views/Shared/index.ascx

The application works fine when running inside of visual studio web developer express SP1 and also works when configured as the top level web site.

I'm developing under XP (IIS 6ish) so I've already configured the wildcard mappings etc. The MVC app is configured as a virtual folder directly underneath the root web site (http://localhost/ROHAS where ROHAS is the virtual folder pointing to my MVC solution). I've also tried adding routes in the global.asax.cs to compensate for the sub application's virtual path:

routes.MapRoute("NetPortal",    // Route name<br>
            "localhost/rohas/{controller}/{action}/{id}");

and also

routes.MapRoute("NetPortal",    // Route name<br>
            "rohas/{controller}/{action}/{id}");

I've even tried adding another virtual folder that just points to the Views folder in my MVC solution.

However, I still get the error detailed above.

Earlz
  • 62,085
  • 98
  • 303
  • 499

2 Answers2

2

You have to create a Virtual Directory in the website youre using the MVC project in, with the name 'Views', which points to the Views directory in your MVC project. Make sure to just create a VD with only 'Read' access in IIS Manager, and make also sure you do not have a Application for the VD.

(VD -> Properties -> Make sure the application section is greyed out)

Jan Jongboom
  • 26,598
  • 9
  • 83
  • 120
  • Thanks for the answer but I already tried that. I did mention that in my original post but I didn't just give it read permissions - I'll try again and let you know. Thanks again. –  Sep 04 '09 at 12:29
  • Hmmm..seems I'm wrong (as usual). I did as you suggested even though I thought I'd already done it once and it worked like a charm, thankyou very very much. –  Sep 04 '09 at 12:41
  • I think that was it - I must have created it (the Views VD) as an application before...many thanks again m8y. –  Sep 04 '09 at 12:44
  • While I'm on ;), It seems that after I've configured IIS for the widcard processing it has stopped serving up .asp pages (I didn't mention that the existing site has classic asp also)...any ideas..? –  Sep 04 '09 at 12:45
  • Actually this only works when running inside of visual studio web express...outside of that it fauls the same.. –  Sep 04 '09 at 13:27
2

It appears that your view file is missing. Your employmentController is attempting to return a view/partial view named index.aspx/index.ascx which cannot be found. You should place your view in the ~/Views/employment folder of your mvc.net application directory. Or it can be placed in the ~/Views/Shared/ folder

The error has nothing to do with your routing in your global.ascx file

David Glenn
  • 24,412
  • 19
  • 74
  • 94