Question

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?

Was it helpful?

Solution

Prefix it with '/Views' should help.

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top