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

The Archive Base Latest Questions

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

I have a controller with 2 actions that each return the response from the

  • 0

I have a controller with 2 actions that each return the response from the Index action after setting a given parameter.

public ActionResult Index(int? pageType)
{
    // Do something based on the pageType
    return View();
}

public ActionResult Guides()
{
    return Index(1);
}

public ActionResult Discussions()
{
    return Index(2);
}

The reason I do this is to make the Url a bit cleaner without messing too much with routing (setting the route to accept the page type as string parameter would confuse things with mapping to the controller actions, and I wanted the url to show the page type)

Just to confuse things, I dynamically check for a matching view based on the pageType parameter and use that, otherwise I stick to the default ‘Index’ view. I’m using the standard route mapping to catch this.

As is often the case, this all works wonderfully locally. The problem comes when accessing the Url on the web server. When I navigate to the ‘Guides’ action it all works fine, however navigating to the ‘Discussions’ action returns a 404. The strange thing is that accessing the same Url in a browser on the server itself works fine!

It’s running on Windows Server 2008 R2 (IIS7) with application pool set to Integrated. It’s also MVC 3 on .Net 4.

Has anyone seen anything like this before or have any idea how to diagnose? I’m not sure where to go from here…

EDIT:

OK so for brevity I missed out some things that I didn’t think were relevant, how wrong I was…

In addition to the pageType parameter, there’s also an optional category. This checks that the category exists in the DB and adds it to the view model.

Within the View, there is a call to @Html.RenderAction which sends the category Id to another action method. I’m not sure why I did it this way instead of just calling @Html.Partial passing in the model but hey. Anyway if the category was not found, this action method returned a HttpNotFound result, hence the 404.

I just changed the ‘child’ action method to return the partial view using an empty object as the model (a new empty list in my case) and it fixed the issue.

It took a bit of digging but I got there in the end, in future I’ll be sure to use RenderAction only when I really need to do additional action processing that can’t be done in the initial controller action.

Of course, this doesn’t help explain why it worked when accessing locally on the server. I guess that must be something to do with the HttpNotFound result.

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

    So, just to resolve the question. In the parent View I had a call to @Html.RenderAction which in turn executed the code below:

    public ActionResult SubCategories(string categoryName)
    {
        Category category = CategoryRepository.GetCategory(categoryName);
        if (category == null)
            return HttpNotFound();
    
        return PartialView("Categories", category.SubCategories);
    }
    

    This was returning a HttpNotFound() ActionResult which in turn resulted in a 404 for the parent view.

    I changed the code to use an empty list as the model if not found and that solved the problem.

    public ActionResult SubCategories(string categoryName)
    {
        IList<Category> subCategories = new List<Category>();
    
        Category category = CategoryRepository.GetCategory(categoryName);
        if (category != null)
            subCategories = category.SubCategories;
    
        return PartialView("Categories", subCategories);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following action/controller on MVC3: [HttpPost] public ActionResult AX_AddItemResponse(ItemResponsesVM response) { return
I have multiple controller actions that takes an id public ActionResult Get(int? id) {
If I have an ASP.NET MVC controller action that is called from a jQuery
I have a spring action that I am rendering some json from the controller,
I'm using Zend framework, and most of the action controller that I have return
I have a controller action that is being executed by a link that was
I have a controller action that checks this.User.Identity.IsAuthenticated What do you suggest how to
If i have a Controller Action that may recieve both HTTP GET and HTTP
I have a HTML form, and I have a Controller Action that accepts the
If i have a controller action Create that returns a view with the following

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.