Hi there,
I wonder if anyone can help, i wish to save a variable globally for the current user on the current page, i thought Sessions are bad in mvc??
I should give an example of what i am doing. Basically i have a controller and it enters (Action = Index) and i check
Request.UrlReferrer
And if it contains a value that means it arrived from another place i.e. Google for example. And i write the information to a log. Now at this stage in the controller all is fine.
But later in my page i wish to recall a method in the controller (using jquery and ajax) to process some more tracking but remembering i am still in the same page, i use
Request.UrlReferrer
but at this stage its always going to be the name of the page as the referrer is the page that initiated the ajax call and "NOT" google. Ok so it appears i need to save the value or UrlReferrer to a global variable/per user so that when i reenter my controller i can check this SAVED variable rather thatn Request.UrlReferrer.
Does anyone know the easiest way to do this?
here is an example of my page
public ActionResult Index()
{
// Process tracking - Initial entry
string ip = Request.UserHostAddress.ToString();
string referrer = null;
if (Request.UrlReferrer !=null)
referrer = Request.UrlReferrer.ToString();
// WRITE THE LOGS HERE!!!!
return View();
}
public ActionResult ProcessTracking()
{
// Reprocess tracking
// BUt can't use Request.UrlReferrer as it returns my calling page and not google
// for example
//string ip = Request.UserHostAddress.ToString();
//string referrer = null;
//if (Request.UrlReferrer != null)
// referrer = Request.UrlReferrer.ToString();
//return View();
}