I need to do some preprocessing before each request, but how?
Hello,
I run a multilingual site. I have set up two homepage nodes that are tied to different domains with the "manage domains" option.
For each request, I need to know what the current homepage is. On my dutch .nl domain this should be the Dutch homepage node and on my English .com domain this must be the English homepage node.
I want to make the current homepage node available to all .NET user controls in my site. So it should be somehow inherited if that is possible.
How would I do this in .NET? The only way I can think of is doing it in my Master.master page and adding the current homepage Node to the request, but isn't there a better way?
I would propably add property to my masterpage and create a base user control that can access that property then all my other controls would derive from that base usercontrol,
That is a good idea too. I think you mean by adding a property to the Master.master's code behind? We're not working with code behind files for master pages in our project, but I suppose there is no reason why I shouldn't add a code behind.
I am still trying to figure out how to get this done. I am trying to make a Settings object available to all my user controls.I had a solution where I created the Settings object in the codebehind of Master.master, but this doesn't always work, because .NET loads the most specific master file first, and less specific master master pages afterwards. For example, when I am on a category page, .NET will first run Category.master.cs and then Master.master.cs. So, when I try to access the Settings object from Category.master.cs I get a nullpointer.
Another thing I tried is to put a macro at the top of the Master.master that just initializes and fills a Settings object, but this doesn't work at all, because master pages are processed before (.NET) macro's.
The last thing I tried was to use a HttpModule. I got the module working, but cannot get the CurrentNode() because it doesn't exist yet. I have looked in the UmbracoContext because I read somewhere that there is a pageId that I can use to get the current node, but the pageId is always null.
And now... I am out of solutions, so I hope you can help. I want to create a Settings object that is recreated for every request and that can be accessed from master pages code behind files and from user controls.
I need to do some preprocessing before each request, but how?
Hello,
I run a multilingual site. I have set up two homepage nodes that are tied to different domains with the "manage domains" option.
For each request, I need to know what the current homepage is. On my dutch .nl domain this should be the Dutch homepage node and on my English .com domain this must be the English homepage node.
I want to make the current homepage node available to all .NET user controls in my site. So it should be somehow inherited if that is possible.
How would I do this in .NET? The only way I can think of is doing it in my Master.master page and adding the current homepage Node to the request, but isn't there a better way?
Actually, what I am looking for is the .NET equivalent of a Java filter and I think I may have found an answer at stackoverflow.com
http://stackoverflow.com/questions/5436061/net-equivalent-of-java-servlet-filters
Think you don't need any kind of perprocessing.
I would propably add property to my masterpage and create a base user control that can access that property then all my other controls would derive from that base usercontrol,
Hope this helps you
That is a good idea too. I think you mean by adding a property to the Master.master's code behind? We're not working with code behind files for master pages in our project, but I suppose there is no reason why I shouldn't add a code behind.
Yes indeed it's normal asp.net Masterpages.
I am still trying to figure out how to get this done. I am trying to make a Settings object available to all my user controls.I had a solution where I created the Settings object in the codebehind of Master.master, but this doesn't always work, because .NET loads the most specific master file first, and less specific master master pages afterwards. For example, when I am on a category page, .NET will first run Category.master.cs and then Master.master.cs. So, when I try to access the Settings object from Category.master.cs I get a nullpointer.
Another thing I tried is to put a macro at the top of the Master.master that just initializes and fills a Settings object, but this doesn't work at all, because master pages are processed before (.NET) macro's.
The last thing I tried was to use a HttpModule. I got the module working, but cannot get the CurrentNode() because it doesn't exist yet. I have looked in the UmbracoContext because I read somewhere that there is a pageId that I can use to get the current node, but the pageId is always null.
And now... I am out of solutions, so I hope you can help. I want to create a Settings object that is recreated for every request and that can be accessed from master pages code behind files and from user controls.
is working on a reply...