Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6159763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:11:12+00:00 2026-05-23T21:11:12+00:00

I am implementing a new ASP.NET MVC 3 application that will use a form

  • 0

I am implementing a new ASP.NET MVC 3 application that will use a form of dynamic routing to determine what view to return from a common controller action. I’d like have a default view that is displayed if there is no view at the dynamic location.

Think of it like navigating a tree structure. There is only one TreeController located in the root Controllers folder. It has a Browse action method that accepts the path of the node to browse. Each node can have a custom view so I need to first attempt to locate that view and return it from the action method, like this:

public ViewResult Browse(String path)
{
    var model = ...;

    return View(path, model);
}

So, if I navigate to “MySite/Tree/A/B/C” then I would expect to find a view at “\Views\Tree\A\B\C.aspx”.

However, if there is not a custom view, I need to defer to a standard/default view (such as “\Views\Tree\Browse.aspx”).

Since this is only the case for this action method, I don’t believe that I should be handling NotFound errors that may result due to other circumstances. And, I’m not looking for dynamic routing as described in other posts because the path to the controller is fixed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T21:11:14+00:00Added an answer on May 23, 2026 at 9:11 pm

    Controllers shouldn’t know about physical views.

    You do this by writing a custom view engine, e.g.:

    public class MyViewEngine: WebFormViewEngine
    {
        public MyViewEngine() 
        {
            ViewLocationFormats = ViewLocationFormats.Concat(
                new [] {"~/Views/{1}/Browse.aspx""}).ToArray();
            // similarly for AreaViewLocationFormats, etc., if needed
        }
    }
    

    See the source code for, e.g., WebFormViewEngine for details.

    If you need to do this conditionally (for only a few action) then you can override FindView in that type and look at the route values.

    Obviously, if you use Razor, then change that one instead.

    Then, in Global.asax.cs, use it:

    private void Application_Start(object sender, EventArgs e)
    {
        // stuff
        ViewEngines.Engines.Add(new MyViewEngine());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am implementing the URL Routing in my asp.net application, in that my some
I'm implementing the repository pattern in my ASP.NET MVC application. So i was doing
Here's the situation... Site 1) ASP.NET MVC application for customers to login, view and
I'm new to DDD. I have an existing ASP.NET application (not MVC) and I
I'm in the process of converting parts of an application to use ASP.NET MVC
Let's suppose I want to add a new feature to my ASP.NET MVC application
Is it worth implementing P3P on a new asp.net website/web application? Or any website
I'm implementing some asp.net application in .NET Framework 1.1. Within that application I want
I am new to ASP.Net MVC 3, facing some issues while trying to implementing
I'm implementing CAPTCHA in my form submission as per Sanderson's book Pro ASP.NET MVC

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.