Reputation: 327
I'm having an extremely hard time figuring out how to use my Return RedirectToAction to send it to my other view in a different controller with parameters.
I have the following code
return RedirectToAction("Notice", "?Redirect=Notice");
I would basically like to go to mywebsite.com/?Redirect=Notice/Notice
Could anyone please advise how to do so?
Upvotes: 0
Views: 435
Reputation: 36073
RedirectToAction
will redirect to a "Controller/Action" combination. The "Home/Index" combination by default is shortened to "/". If you want to redirect to something else (for example, the root of your website, use something other than RedirectToAction()
.
For example:
return Redirect(Url.Content("~") + "?Redirect=Notice/Notice");
Upvotes: 1
Reputation: 239290
I'm not sure why @ClaudioRedi deleted his answer but it was correct:
return RedirectToAction("Notice", new { Redirect = "Notice/Notice" } );
If that takes you to the wrong URL, then that's due to using the wrong action name. I'm not sure how you have referenced your home page, but you should be using something along the lines of:
return RedirectToAction("Index", "Home", new { Redirect = "Notice/Notice" } );
To reach the root of your site.
Upvotes: 1