身份模型声明中包含 XML 字符
我想做一些类似的事情
outputIdentity.Claims.Add(new Claim("Claim1", "<test>Hi</test>"))
,但是响应标头本身中的安全节点会显示它,因为
<Attribute Name="Claim1"><AttributeValue><test>Hi</test></AttributeValue></Attribute>
我知道它们是要翻译的保留 XML 字符,但我不能指定我想要在我的属性中使用该节点结构吗?
注意:我也尝试将其包装在 CDATA 中,但它也会序列化该标签。当我替换翻译的字符时,它起作用了。
I'd like to do something like
outputIdentity.Claims.Add(new Claim("Claim1", "<test>Hi</test>"))
However the security node within the response header itself shows it as
<Attribute Name="Claim1"><AttributeValue><test>Hi</test></AttributeValue></Attribute>
I know they are reserved XML characters getting translated but can't I specify that I want that node structure in my attribute?
NOTE: I've also tried wrapping it in CDATA however it serializes that tag too. When I replace the translated characters, it works.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
安全令牌的序列化由
SecurityTokenHandler
完成(在您的情况下可能是Saml11SecurityTokenHandler
)。如果您想自定义序列化,则必须通过扩展
Saml11SecurityTokenHandler
类来覆盖默认行为:您还必须在 web.config 文件中添加自定义安全令牌处理程序:
编辑:删除了
Serialization of security tokens is done by the
SecurityTokenHandler
(in your case probably theSaml11SecurityTokenHandler
).If you want to customize serialization you have to overwrite the default behaviour by extending the
Saml11SecurityTokenHandler
class:You also have to add your custom security token handler in the web.config file:
EDIT: removed
<clear />
您可以尝试将值包装在 CDATA 部分中吗?作为:
Not sure whether your SecurityTokenHandler class will handle that properly, but it's worth a try, and easier than introducing custom handlers.
Can you try wrapping the value in CDATA section? As:
Not sure whether your SecurityTokenHandler class will handle that properly, but it's worth a try, and easier than introducing custom handlers.