1

I have a view folder structure:

  • Views
  • Admin
  • Post
  • New

and routing is defined with:

 routes.MapRoute(
            "Admin", // Route name
            "Admin/{controller}/{action}/{id}", // URL with parameters
            new { controller = "Admin", action = "Index", id = UrlParameter.Optional }
        );

But, for ex: /Admin/Post/New gives 404 error. Because It doesn't go to Admin folder first.

Err: The view 'New' or its master was not found. The following locations were searched: ~/Views/Post/New.aspx ~/Views/Post/New.ascx ~/Views/Shared/New.aspx ~/Views/Shared/New.ascx

How I can define the folder?

2
  • Do you also have matching controllers for your views? Also, what's with the underscored in front of the view paths? Commented Jul 25, 2010 at 9:54
  • Yeah I have controllers. Underscores are just for to show the subs. Commented Jul 25, 2010 at 10:11

2 Answers 2

3

Rather than creating subfolders like that under Views, take a look at Areas. This may better help solve your problem.

Sign up to request clarification or add additional context in comments.

Comments

0

You don't need to do that. The web.config file in the /Views folder prohibits any views being accessed directly. Users won't be able to visit www.yoursite.com/Views/___Admin.

I'd rename them back to /Admin, /Post, /New etc.

Otherwise, you need to create a new ViewEngine (you can extend the WebFormsViewEngine) to supply the additional paths.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.