What I am trying to do is basically set the URL to take you to a webpage that uses your last known parameters.
-
You visit a page with parameter show all set false, so it shows non in list.
-
You then change show all to true. So it shows all in list.
-
An hour later you revisit that page. It knows you last had show all to true.:
MR Controller – Index:
HttpCookie mr1 = new HttpCookie("MR1", "test");
Request.Cookies.Add(mr1); // Save all parameters used in cookies. (WORKING).
View with button:
<input type="button" class="cancel" value="Cancel" onclick="location.href='@MyNS.Helpers.HtmlHelper.MRUrl(Request.Cookies)'">
MyNS.Helpers.HtmlHelper:
public static String MRUrl(COOKIES? myCookie)
{
//If not null, add to object array.
myCookie["MR1"].Value;
myCookie["MR2"].Value;
return @Url.Action("Index", "MR"); // Plus non null variables as parameters.
}
What I cant do is access any Cookies via my helper. Nor do I know if this is the best way to do it. I just want to take out the cookie info that has the parameters used, and use it to build the required URL.
There will be 6-7 different index page variable storing methods.
I think you want a UrlHelper extension like this:
You can then use this in any view like so:
Or in the case of your button…
Edit: You’d need to import the namespace of the UrlHelperExtensions class before using the helper, obviously.