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

  • Home
  • SEARCH
  • 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 7713947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:59:57+00:00 2026-06-01T01:59:57+00:00

I have opened a sample ASP.NET MVC project. In HomeController I have created a

  • 0

I have opened a sample ASP.NET MVC project.

In HomeController I have created a method (action) named MethodA

public ActionResult MethodA()
{
    return View();
}

I have right clicked on MethodA and created a new view called MethodA1

Re-did it and created a new view called MethodA2.

  1. How is this magical relationship done? I looked for the config to tell the compiler that views MethodAX are related to action MethodA, but found none.

  2. What view will the controller return when MethodA is called?

  • 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-01T01:59:59+00:00Added an answer on June 1, 2026 at 1:59 am

    The convention is that if you don’t specify a view name, the corresponding view will be the name of the action. So:

    public ActionResult MethodA()
    {
        return View();
    }
    

    will render ~/Views/ControllerName/MethodA.cshtml.

    But you could also specify a view name:

    public ActionResult MethodA()
    {
        return View("FooBar");
    }
    

    and now the ~/Views/ControllerName/FooBar.cshtml view will be rendered.

    Or you could even specify a fully qualified view name which is not inside the views folder of the current controller:

    public ActionResult MethodA()
    {
        return View("~/Views/Foo/Baz.cshtml");
    }
    

    Now obviously all this assumes Razor as view engine. If you are using WebForms, replace .cshtml with .aspx or .ascx (if you are working with partials).

    For example if there is no view it will even tell you where and in what order is looking for views:

    enter image description here

    Remember: ASP.NET MVC is all about convention over configuration.

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

Sidebar

Related Questions

I have created a new MVC2 project using the ASP.NET MVC2 Web Application, which
I have extended DotNetOpenAuth ASP.NET MVC Login sample while trying to get at least
I have various simple ASP.NET MVC views for CRUD operations which work fine on
I have an ASP.Net MVC Page with a very simple form on it: One
I have a view in asp.net mvc 3, and I need to open it
I have a simple ASP.NET MVC + OpenID + NHibernate app (on top of
I have an ASP.net project which involves using a custom IHttpModule. This module will
I'm using OpenId in my ASP.NET MVC application. Works great :) Once i have
I am writing a SharePoint web part which will have a simple ASP.NET form.
I have a document that my asp.net page is creating and I need to

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.