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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:47:40+00:00 2026-05-23T18:47:40+00:00

Imagine a page where the user can update, delete, edit or even vote the

  • 0

Imagine a page where the user can update, delete, edit or even vote the input. Since each action will be handled by a different ActionResult, the url of the page will have to change in case there are errors. My question is simple: Say your page is “http://localhost/Input/” and when you there are some errors, I want to redirect to “http://localhost/Input/Error” and display an error message. I don’t want to use sessions for this therefore please don’t show me this link. Basically, want I want to do this is something similar:

public ActionResult Create(FormCollection form) { 
        try {
            // some code here
            return RedirectToAction("Index");
        }
        catch () {
             string errorMessage = "You have done something bad!"; 
             // and I want to pass this string to my Error Action.
             return RedirectToAction("Error"); 
        }
}

The Solution I’ve Used

I know that I said I don’t want to use TempData, but apparantly that is the best option and I’ve used that for my issue. As for the answer I’ve chosen DigBySwift’s answer because that’s the most logical thing you can do if you don’t want to use Session for this type of operation.

  • 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-23T18:47:40+00:00Added an answer on May 23, 2026 at 6:47 pm

    As you say, if you don’t want to use sessions then TempData is not an option. Ideally, you should try not to pass the error message to the next page. Instead store the error message(s) in a resource file.

    You could pass an id/enum to you next page and then retrieve the error based on the passed parameter:

    return RedirectToAction("Error", new { ErrorId = 4 });
    
    public ActionResult Error(int errorId){ ... }
    

    Edit: An alternative (since a db write-read would be expensive considering) would be to write the message to a cookie and then retrieve it after the redirect, and then delete the cookie. This is not great and I personally would not use this. But if you need to customise the message, it is an option.

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

Sidebar

Related Questions

Imagine that HTML page is a game surface (see picture). User can have n
Let's imagine you have an asp.net page in front of you full of input
Imagine this simple form for uploading a file: <form action=upload enctype=multipart/form-data> <input type=text name=name/>
Imagine that you have several links on a page. When you clicked, a div
Imagine the scenario you have a listing page that is a concatenation of multiple
Imagine I have a navigation bar in my page header, with a number of
I have a vertically scrolling uiscrollview - imagine an 'about this app' page of
I've got a page layout for a publishing site with an odd behaviour. Imagine
I have user control inside a page with single repeater. The problem is when
I am building a sign up page for user to sign up as a

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.