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 8854847
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:58:42+00:00 2026-06-14T13:58:42+00:00

For controllers Foo , Bar , and Baz , I have a folder structure

  • 0

For controllers Foo, Bar, and Baz, I have a folder structure that looks like this:

Views
    Foo
        Index.csthml
    Bar
        Index.csthml
    Baz
        Index.csthml
        _Rarity.cshtml

Must it really be this way? It’s a bit of a pain to determine the right file to edit because most of them are called Index.cshtml. Ideally I’d like something a bit more like this:

Views
    Foo.csthml
    Bar.csthml
    Baz.csthml
    Baz
        _Rarity.cshtml

I’m aware that I can pass a fully-qualified path to the View() method of the Controller class; i.e. inside of FooController‘s Index() method, I can call this.View("~/Views/Foo.cshtml"). Is this the best I can get?

  • 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-06-14T13:58:44+00:00Added an answer on June 14, 2026 at 1:58 pm

    This fits outside of the nature of the default Razor view engine; it’s a conventional approach to use the first setup as you mentioned above. However, you could build your own convention by customizing the Razor view engine, and the folder it needs to look for views in. However, the problem that you may experience with your design is conflicting file names; For instance, you could make the case that Foo.cshtml maps to Foo controller, Index action, but that means you couldn’t easily map Foo controller Another action method to a view without a special convention for it.

    Conclusion: yes, with customizations, but beware of complexity and edge cases.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In one of my controllers, I do have a return that looks like this:
I have a ruby hash that looks like this { stuff_attributes => { 1
Having this route: map.foo 'foo/*path', :controller => 'foo', :action => 'index' I have the
I have my main view like this: <%@ Page Title= Language=C# MasterPageFile=~/Views/Shared/Site.Master Inherits=System.Web.Mvc.ViewPage %>
Say I have two independent classes: class Foo { int bar; } class Baz
I've got a set of routes that looks like this: resources :placements do match
I have a model, Foo, that has_many Bars. It has a virtual attribute, current_baz,
I have done a posting using httparty. E.g. options={ :foo => '123' :bar =>
I have two models: Bar HABTM Foo. Now I have bars_foos join table with
Let's say I have a file located at C:\foo\bar.js and I want to include

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.