继these说明我能为一个配置文件添加此到Web.config中定义自定义属性:自定义配置文件属性
<profile defaultProvider="DefaultProfileProvider">
<providers>
<add
name="DefaultProfileProvider"
type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
connectionStringName="MYCONEXION"
applicationName="MyApp" />
</providers>
<properties>
<add name="IdRole" type="Integer" />
<add name="IdUser" type="Integer" />
</properties>
</profile>
我发现的问题是,我可以访问此属性(Profile.IdRole
)时分组码采用嵌入式在脚本中,在块<script language="vb" runat="server">
。
当代码块在CodeBehind中时,它看起来像Profile实际上是一个不同的对象/类。另外,如果我将代码从CodeBehind移动到嵌入块,我遇到了一些其他类和方法的问题,例如Security.Cryptography.SHA1CryptoServiceProvider
或我自己项目中的模块中的函数。
我想我错过了一些前缀到Profile.IdRole
从CodeBehind访问它时,你能帮忙吗?
错误信息:
在代码隐藏,当我使用Profile.IdRole
我得到错误IdRole不是档案的成员。
如果我使用HttpContext.Current.Profile.IdRole
我得到IdRole不System.Web.Profile.ProfileBase
当我使用嵌入式代码Profile.IdRole
,将鼠标在它的成员,我得到一个tooltop:只读保护Property Profile作为ProfileCommon,现在我看到ReadOnly我不确定我是否遵循正确的文档...帮助?
谢谢
尝试'HttpContext.Current.Profile'? – RobH
不,不同的错误,但也是一个错误,我会更新这个信息的问题 –
你是否在你的代码中使用VB或C#? – RobH