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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:15:54+00:00 2026-06-04T06:15:54+00:00

I have created a Asp.net MVC application. Now required 404 handling. Have updated global.asax

  • 0

I have created a Asp.net MVC application. Now required 404 handling.

Have updated global.asax and display 404 page based on status code. Also added customErrors property in web.config. Its working fine.

Now I would like to redirect to 404 programmatically when any thing not match with our requirement.

i.e.

if(!valid) 
{
    return RedirectToAction("Index", "Page404");
}

It’s working fine but there are 2 status one is 301 & then 404. So how can I prevent 301? I just need 404.

How can I achieve this?

  • 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-04T06:15:55+00:00Added an answer on June 4, 2026 at 6:15 am

    In your web.config, add:

    <customErrors mode="On" >
           <error statusCode="404" redirect="/404.shtml" />
    </customErrors>
    

    This will redirect on 404.shtml page when requested resource is not found.

    Note: No need to programmatically redirect users for such situation.


    EDIT:
    I literally suggest:

    if (Context.Response.StatusCode == 404) {
      // handle this
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created blank Asp.Net-MVC 3 web application and want to write my own
I have created a new ActionFilter for an ASP.NET MVC application that I'm creating.
I have created an multi thread application on IIS (ASP.NET MVC), When the threading
I created a simple ASP.NET MVC version 1.0 application. I have a ProductController which
I have created an otherwise empty ASP.NET MVC 3 application with 2 controllers, HomeController
I have asp.net mvc 2 application. Now I'm reimplementing it for working with Ninject
I’ve created an ASP.NET MVC 4.0 application. Now I’m trying to find a 3rd
I have defined an area (Admin) in my ASP.NET MVC 3 application, created _ViewStart.cshtml
I have an ASP.NET MVC 3 application which has a post action called Create
I have created firstly ASP.NET MVC 2 . and write more functionality. After I

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.