tags:

views:

55

answers:

2

Hello guys,

This is simple xslt, that shows the login status of the current user. Everything worked fine on development server, but once we've setup app on production, umbraco.librarty.IsLoggedOn() started always to return false.

Application uses method umbraco.libraty.IsLoggedOn() from .NET code and from there it returns proper value, but from xslt doesn't.

 <xsl:choose>
  <xsl:when test="umbraco.library:IsLoggedOn() = true()">
   You are logged in as 
    <q>
      <xsl:variable name="user" select="umbraco.library:GetCurrentMember()/@loginName"/>
      <xsl:value-of select="$user"/>
    </q>.  This is <a href="/profile">your profile</a>.
  </xsl:when>
  <xsl:otherwise>
   You are not logged in.
    <a href="/registruj-se">Log in</a>.
  </xsl:otherwise>
</xsl:choose>

For non-umbraco developers: the library.IsLoggedOn() function checks HttpContext.Current.User and HttpContext.Current.User.Identity.IsAuthenticated to see if you is logged in or not.

Maybe it is a problem with cookies and XSLT? Anyone have a clue? Tnx

+1  A: 

Change

<xsl:when test="umbraco.library:IsLoggedOn() = true()"> 

to

<xsl:when test="umbraco.library:IsLoggedOn()"> 
riffnl
Hi riffnl, tnx for you answer. Initially it was just IsLoggedOn(), then, I've changed it to IsLoggedOn() = test() by recommendation on Umbraco forum.
Misha N.
Can you add IsLoggedOn() to output like: <xsl:value-of select="umbraco.library:IsLoggedOn()"/> to see what the value actually is?
riffnl
the actual value was 'false'. However, it was the problem with configuration, not with xslt. See my answer below. tnx for help
Misha N.
A: 

Ok, this is solution to my problem.

The session was not available from xslt, neither from ascx control that tried to access session from codebehind. Our application is 99% using asp.net webservice with methods marked with [WebMethod(EnableSession = true)]. Inside of these methods, session was available. That made me think that session is actually disabled on the web site by default.

After some googling, I find out that I have to add this property to web.config file:

<system.webServer>
<modules runAllManagedModulesForAllRequests="true">

Apparently, the machine.config in our development had this property as default, and production server didn't, so it needed to be changed in web.config.

Misha N.