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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:23:48+00:00 2026-06-05T15:23:48+00:00

I have a private function like this in my controller. private UserDetails GetUserDetails(int userid)

  • 0

I have a private function like this in my controller.

private UserDetails GetUserDetails(int userid)
{
    ...
    if (some condition check is false)
        Redirect("some other page in a different subdomain");

    return userDetails;
}

If the condition fails, Redirect statement is executed, but the execution doesn’t stop. userDetails is returned to the calling function. There is no redirect to some other page.

How can I force the redirect?

  • 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-05T15:23:49+00:00Added an answer on June 5, 2026 at 3:23 pm

    Redirect returns a result – you’re meant to use it from within an Action method as follows:

    public ActionResult MyAction() 
    {
        if (check is false) 
        {
            return Redirect("other url");
        }
        // this code won't get executed after redirect
    }
    

    It looks like you should return null from the function you posted above, then check for null and return Redirect("...") if GetUserDetails returned null.

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

Sidebar

Related Questions

I have a function like this: private void GetRSS(int start, int end) { for
I have a function that loads in some XML that looks like this: private
I have a function like this in actionscript3 private function uploadFile(event:MouseEvent):void { var uploader:URLRequest
I have a ComboBox with a label function like this one: private function fieldLabelFunction(item:Object):String
I have an array of function callbacks, like this: class Blah { private var
Suppose we have this code: class My_controller extends CI_Controller { private $model_name; function __construct($model_name)
I have written a template function like this: template <class T> const T& max1(const
I have a label function like : private function formatDate (item:Object, column:DataGridColumn):String { var
I have a function that returns the request parameters for each request: private function
I have the following function using Excel 2010: Private Function MakeAllSheetsValuesOnly(targetBookName As String) If

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.