0

my first actioncontroller is:

 return RedirectToAction("Index", "Authentication",new {code = result });

and i use the "result" parameter in diffrent controller. like

  public ActionResult Index(string code)
        {
            ...
            TempData["valcode"] = code;

            return View();
        }



 [HttpPost]
        public ActionResult AuthenticateUser(string validationcode)
        {
            if (validationcode == TempData["valcode"].ToString())
            {
                return RedirectToAction("Index", "Home");
            }
            else
            {
          ...
            }
        }

it works fine but in url, i see the code value. (http://www.test.com/Authentication/code=123) i dont want code value to be seen in url

how can i hide it from url? (besides encrypting)

1
  • You cant. Your controller method is not psychic. If you do not pass the value, then the controller cannot receive it. You can always use TempData but that only lasts one request and would be lost if the user refreshed the browser. Commented Jun 20, 2017 at 5:55

1 Answer 1

2

Try Using Sessions to pass data between controllers.

Session["valcode"] = code;

But note that, using sessions to pass data between controllers is a bad idea because it will use the app pool of the application which will eventually slow down the application. If using sessions is mandatory, make sure you destroy session variables after being used.

Hope this helps.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.