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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:51:38+00:00 2026-05-13T08:51:38+00:00

I have a catch-all route setup in ASP.NET MVC, so I can capture /this-page,

  • 0

I have a catch-all route setup in ASP.NET MVC, so I can capture /this-page, /that-page etc.

When you hit a page the action is invoked, say Index(string page) and then page is tested against a value in the database to determine if the page can be found. If it can’t be found, I want to display the view FileNotFound which is in my ErrorController, I do not want to redirect as I want to keep the url as http://…/page-that-isnt-found, exactly like StackOverflow does in fact if you give it a bogus question – (https://stackoverflow.com/questions/zzz-aaa).

Now my problem lies with figuring out the code, I have tried both:

[ do page db check ]
if (page == null)
   return RedirectToAction("FileNotFound", "Error");
   // return View("FileNotFound"); // can't opt for a controller ?

The closest I get is with RedirectToAction(), however of course it does an actual redirect, and my url is pointed at /error which is not desired behaviour. I have tried using return View() but it seems I can’t specify a controller, only the view name?

  • 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-13T08:51:38+00:00Added an answer on May 13, 2026 at 8:51 am

    Correct, by returning a View, you are pointing to a View name to be rendered, not an ActionMethod. You should be able to create a View (either in the same controller’s views or the shared views) that you return that contains your 404 page content.

    Hope this helps.

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

Sidebar

Related Questions

In ASP.NET MVC, I have a defined catch-all route as below: routes.MapRoute( TagsRoute, tags/{*tags},
I have an mvc app that has a catch all route setup that occasionally
I have a route in my asp.net mvc 2 site that looks like this
I have a route defined last in my ASP.Net MVC 2 app that will
I have a custom routehandler in ASP.NET MVC2 to catch all url's at a
I have an ASP.NET WebForms application that I'm trying to switch to MVC for
Why in ASP.NET MVC is it when I use a: return this.RedirectToAction(Index, Page, new
So, I have a catch all route that is going to act like a
Is there any that I can have a catch all site with flatpage framework
I want to have a 'catch all' route which runs when none of the

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.