I need to a method to either pass back a string value or Redirect to another method. Is there a method class that can handle both passing back a string or redirecting to another method.
I am using MVC C#.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
You can use a method with return type ActionResult
If you want to return string just use Content(string) method:
If you want to redirect to another action, use RedirectToAction(string) method:
Both
Content(string)andRedirectToAction(string)are methods of MVC’s Controller class.As a summary you write your Controller like this: