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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:54:55+00:00 2026-05-16T20:54:55+00:00

Hey, one more newbie here, just playing around with .NET MVC. My main task

  • 0

Hey, one more newbie here, just playing around with .NET MVC. My main task is to have a few semi-static pages on URLs like:

  • /about/
  • /about/contacts/
  • /about/jobs/

I’m using a controller for that called Static and have the following route attached:

routes.MapRoute(
  "About",
  "about/{id}",
  new { controller = "Static", action = "Index", id = UrlParameter.Optional }
);

It seems to work fine as I have the Static controller with the Index method which uses a switch statement to identify which page has to be viewed. I use the RedirectToAction() function to call other actions of the Static controller in order to display pages with other views. My views are:

  • /Static/About.aspx
  • /Static/Contacts.aspx
  • /Static/Jobs.aspx

This method seems to work fine, but what I don’t like about it is the redirect, so browsing to /about/contacts I get a redirect to /Static/Contacts which is not what I’d really like to see in the URL.

So my question is – what is the correct way of doing this? And is there a way to explicitly call a certain view from my Index action?

Thanks,
~ K.

  • 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-16T20:54:55+00:00Added an answer on May 16, 2026 at 8:54 pm

    Don’t do the redirect. Instead of using a switch statement within the Index action, have a separate action for each page (ie. About, Contacts, Job) each with their own view.

    Your Static controller could look something like this:

    public ActionResult Index()
    {
        return View();
    }
    
    public ActionResult About()
    {
        return View();
    }
    
    public ActionResult Contacts()
    {
        return View();
    }
    
    public ActionResult Jobs()
    {
        return View();
    }
    

    And if you needed to do any processing specific to Contacts or Jobs, it can be done within their respective actions.

    To explicitly call a certain view:

    return View("ViewName");
    

    There are seven overloads for the View() method. A number of which allow you to pass the Model:

    return View("ViewName", Model);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey, I have some trouble using the stream_publish method, more exactly with the attachment
Hey, I'm pretty new in Spring MVC, and I'm learning the JSP tags and
Hey All- I'm completely new to Django/python and am going through a tutorial for
Hey. I new to OpenGL ES but I've had my share of experience with
Hey folks, beneath is a piece of code i used for a school assignment.
Hey, I am pretty certain I am doing something incorrectly with my lambda expression
Hey guys using POSIX API system calls read , write , open , etc.
Hey all, i am in need of some help trying to figure out why
Hey so I a new to C but a intermediate level programmer in general.
I've got a database table called 'mesg' with the following structure: receiver_id | sender_id

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.