Umbraco.Library.IsLoggedOn() 不适用于 XSLT [英] Umbraco.Library.IsLoggedOn() does not work from XSLT

查看:20
本文介绍了Umbraco.Library.IsLoggedOn() 不适用于 XSLT的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是简单的xslt,显示当前用户的登录状态.在开发服务器上一切正常,但是一旦我们在生产环境中设置应用程序,umbraco.librarty.IsLoggedOn() 开始总是返回 false.

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.

应用程序使用 .NET 代码中的方法 umbraco.libraty.IsLoggedOn() 并从那里返回正确的值,但 xslt 没有.

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>

对于非 umbraco 开发人员:library.IsLoggedOn() 函数检查 HttpContext.Current.User 和 HttpContext.Current.User.Identity.IsAuthenticated 以查看您是否已登录.

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.

也许是 cookie 和 XSLT 的问题?有人有线索吗?Tnx

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

推荐答案

好的,这是我的问题的解决方案.

Ok, this is solution to my problem.

会话无法从 xslt 获得,也无法从试图从代码隐藏访问会话的 ascx 控件中获得.我们的应用程序 99% 使用带有标记为 [WebMethod(EnableSession = true)] 的方法的 asp.net webservice.在这些方法中,会话是可用的.这让我认为默认情况下该会话实际上在网站上被禁用.

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.

经过一些谷歌搜索后,我发现我必须将此属性添加到 web.config 文件中:

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

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

显然,我们开发中的machine.config默认有这个属性,生产服务器没有,所以需要在web.config中更改.

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.

这篇关于Umbraco.Library.IsLoggedOn() 不适用于 XSLT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆