views:

63

answers:

2

I'm trying to access a view in this way:

return View(@"~\Items\Details.aspx");

and I get this error:

The view '~\Items\Details.aspx' or its master could not be found. The following locations were searched: ~\Items\Details.aspx

On the ItemsController, in the Details action, returning View() works just fine. Why can't I access that view from another controller?

A: 

You can make the Items view a shared one (you put it in the Views/Shared folder), then you can just call View("Items") and it will work.

Palantir
Actually, you can. It's not a good design IMHO, but it does work.
Craig Stuntz
Sorry, I edited it in the meanwhile, because I noticed I was wrong: I was suggesting that you could not call views by absolute path.
Palantir
+2  A: 

Prefix it with '/Views' should help.

return View("~/Views/Items/Details.aspx");
Jan Jongboom