Make sure your controller derives from "RenderMvcController" in the Umbraco.Web.Mvc namespace.
Now, the Index method is what runs on every front end umbraco page... If you override that and don't call the base you will effectively stop umbraco from rendering the pages..
However you can override index and do your cookie logic, just make sure you return "base.Index(model)" when you are done.
In my opinion, this is the best way to do what you want... You could make an HttpModule and register it before UmrbacoModule in the web.config, but that would perform like crap and is unnecessary and overkill.
Want to create cookie and store values to it
Hi,
I am using Umbraco 7. I want to create a cookie and store stuff to it relating to each page visited.
To do this, do I need to intercept/hijack every request because it is using MVC? Does the cookie code need to go in the controller?
Or can this be done in the view?
Kind Regards,
You can hijack every request in umbraco by specifying your own controller as the default controller.
Refer to this documentation here.
Scroll down to "Change the default controller".
Make sure your controller derives from "RenderMvcController" in the Umbraco.Web.Mvc namespace.
Now, the Index method is what runs on every front end umbraco page... If you override that and don't call the base you will effectively stop umbraco from rendering the pages..
However you can override index and do your cookie logic, just make sure you return "base.Index(model)" when you are done.
In my opinion, this is the best way to do what you want... You could make an HttpModule and register it before UmrbacoModule in the web.config, but that would perform like crap and is unnecessary and overkill.
is working on a reply...