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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:43:53+00:00 2026-05-11T15:43:53+00:00

I have actions in different controllers that need to check for a some condition

  • 0

I have actions in different controllers that need to check for a some condition before execution. If the condition is not met, I want the user be redirected to another page with instructions on what to do next (the instructions will include a link that the user must follow).

For example SendMessage() action is located in the Message controller:

public ActionResult SendMessage() {     // check if user has enough credit     if (!hasEnoughCredit(currentUser))     {         // redirect to another page that says:          // 'You do not have enough credit. Please go to LinkToAddCreditAction         // to add more credit.'     }      // do the send message stuff here  } 

I want to have a single generic action called ShowRequirements() located in Requirements controller.

In SendMessage() action, I would like to set the message that I want to show to the user and then forward the user to ShowRequirements() action. I just don’t want the message to appear in the URL of the ShowRequirements action.

Is there any way to communicate this data to ShowRequirements() action?

  • 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. 2026-05-11T15:43:54+00:00Added an answer on May 11, 2026 at 3:43 pm

    Okay, I think I was getting it wrong. As John and Andrew mentioned I simply have to pass the data via ViewData to a view.

    So I made a RequirementsPage.aspx in the /views/Shared. Now in whichever action I am, I fill in the ViewData dictionary and pass it to the RequirementsPage.aspx like this:

    public ActionResult SendMessage() {     // check if user has enough credit     if (!hasEnoughCredit(currentUser))     {         // redirect to another page that says:         ViewData['key1'] = 'some message';         ViewData['key2'] = 'UrlToTheAction';         return View('RequirementsPage');     }      // do the send message stuff here  } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a site that need to get some data from a different sit
I have a controller that extends Zend_Controller_Action. It contains some actions that I need
I need some advice. (For those who have already read this before I have
Let say I have a screen name ITEM thats performs different actions: Save, Update,
I have an action method that takes in two different objects. I am posting
I would like to have a form that can submit to two different action
I have 2 actions in a Flash file that I would like to test
I'm new in ASP.NET MVC, I have many actions in my controllers, so they
I need to find a way to put my MVC controllers into a different
I have an MVC3 application and in one of my actions in my controllers

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.