I am trying to have a simpe check session if else function using a piece of code in my master page.
<% if (Request.Session["lang"] == "ENG"){ %> ENG <% }else{ %> GRE <% } %>
I am getting this error CS1061:
'System.Web.HttpRequest' does not contain a definition for 'Session'
and no extension method 'Session' accepting a first argument of type
'System.Web.HttpRequest' could be found (are you missing a using
directive or an assembly reference?)
We do this in xslt (I don't like inline code that much) and have created a dictionary item called "language" that returns a fixed string depening on what language site you are in:
Rik thanks for your answer, I know I can have this through xslt however I need to just test the other way to see if it works.
Mike I tried both and I am getting an error
Session state can only be used when enableSessionState is
set to true, either in a configuration file or in the Page directive.
Please also make sure that System.Web.SessionStateModule or a custom
session state module is included in the
<configuration>\<system.web>\<httpModules> section in
the application configuration.
I can't find any of them in web.config and I am quite newbie to .net What should I need to change in config file? Any ideas
As for the HttpModule, I don't think it is necessary because it should be included in the machine.config file. Anyway, if you need it, tou have to place it also under the system.web section of the web.config which then looks like this:
The default Umbraco installation has the sessionstate line you mention above. I don't really get where the problem is. I also tried the second way but nothing happened either. same error
I might need to go for the xslt solution. Anyway thanks for your support.
A question that comes to mind, if you would use the session data, what would it return? the browser language or the language setting of the current site in Umbraco ?
As far as I know, it would return whatever value you have put in it. The session is not "pre-filled" with information, it is just a kind of dictionary wher you can store the information you want to be easily/rapidly available to all pages. But in order to retrieve a value from the session, you have to first put it in yourself.
Maybe a last try: again under the web.config <system.web> section, put the following line:
<!-- Enable session state for all the pages in the Web application. --> <pages enableSessionState="true" enableViewState="true" enableViewStateMac="true" smartNavigation="true" validateRequest="false" />
If you already have a <pages> element, do not replace it but just make sure that you have the attribute enableSessionState="true" set.
No luck again, I am sorry guys... There is a pages element where all ASPNETAJAX controls are there. I just added the attribute enableSessionState="true" with no luck.
Check the Session lang in Materpage
Hello,
I am trying to have a simpe check session if else function using a piece of code in my master page.
<% if (Request.Session["lang"] == "ENG"){ %>
ENG
<% }else{ %>
GRE
<% } %>
I am getting this error
CS1061: 'System.Web.HttpRequest' does not contain a definition for 'Session' and no extension method 'Session' accepting a first argument of type 'System.Web.HttpRequest' could be found (are you missing a using directive or an assembly reference?)
Any ideas guys?
Cheers,
Giorgos
We do this in xslt (I don't like inline code that much) and have created a dictionary item called "language" that returns a fixed string depening on what language site you are in:
And the xslt code:
Hello Giorgos,
You have to use Page.Session, or just Session would work also I think.
Cheers,
Michael.
Hello,
Rik thanks for your answer, I know I can have this through xslt however I need to just test the other way to see if it works.
Mike I tried both and I am getting an error
I can't find any of them in web.config and I am quite newbie to .net
What should I need to change in config file? Any ideas
Cheers,
Giorgos
Hello Giorgos,
In the web.config file, you should have an entry like this:
As for the HttpModule, I don't think it is necessary because it should be included in the machine.config file. Anyway, if you need it, tou have to place it also under the system.web section of the web.config which then looks like this:
Hope this helps.
Cheers,
Michael.
Thanks Michael,
The default Umbraco installation has the sessionstate line you mention above. I don't really get where the problem is.
I also tried the second way but nothing happened either. same error
I might need to go for the xslt solution. Anyway thanks for your support.
Cheers,
Giorgos
A question that comes to mind, if you would use the session data, what would it return? the browser language or the language setting of the current site in Umbraco ?
Hello Rik,
As far as I know, it would return whatever value you have put in it. The session is not "pre-filled" with information, it is just a kind of dictionary wher you can store the information you want to be easily/rapidly available to all pages. But in order to retrieve a value from the session, you have to first put it in yourself.
Cheers!
Michael.
Hello both,
What I am doing is to set the Session with either ENG or GRE values as the multilinual 1:1 example.
Cheers
Giorgos
Hi Giorgos,
Maybe a last try: again under the web.config <system.web> section, put the following line:
If you already have a <pages> element, do not replace it but just make sure that you have the attribute enableSessionState="true" set.
Good luck :-)
Michael.
Hello,
No luck again, I am sorry guys...
There is a pages element where all ASPNETAJAX controls are there. I just added the attribute enableSessionState="true" with no luck.
Cheers,
Giorgos
is working on a reply...