mvc, onload?, asp.net
Posted on 2013-11-13
I have below cookie function that need to be execute in onload event. And I use mvc 3 and there is no on load event exist, and so I put it within action result in home controller, and expect it will work. Unfortunately, it does not. I need some experts to help me
what to do.
Basically, all i want is to read cookie if cookie exists, do something like below.
and redirect url to some where else. The code is very simple but just don't know where it should stay when the page is loaded....
public ActionResult Index()
//read cookie for the zipcode
string memberZip = Server.HtmlEncode(Request.Cookies["memberZipCode"].Value);
Decimal y = ServCommon.GetLocationConverter(memberZip);
decimal loc1 = y;
decimal loc2 = y;
string x = ServSuretyNetworkRef.GetAgencyListByDistance(loc1, loc2, memberZip, 1, "1");
string locationResult = x;
Response.Redirect("/home?locations=" + locationResult);