视图状态标签上的结束斜杠?
所有,
我注意到 asp.net 在视图状态表单字段上包含一个结束斜杠:
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="blah blah blah" />
如何防止这种情况发生?我们正在严格渲染 html 4.01,但这似乎不合规。
All,
I've noticed that asp.net includes a closing slash on the viewstate form field:
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="blah blah blah" />
How can I prevent this from happening? We're rendering html 4.01 strict and this seems to be noncompliant.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我得到的最终答案是“这并不重要”。无论好坏,这些标签都是按照框架想要生成它们的方式生成的,除了创建一个 HttpModule 来在将标记发送到浏览器之前重新格式化标签之外,您对此无能为力。
不过,没关系。这些标签的验证是无关紧要的。另一位开发人员抱怨标签名称中的下划线(例如“__VIEWSTATE”)也不合规,但事实证明这是 CSS 规则,而不是 HTML 规则。由于没有样式应用于这些标签(并且将 CSS 应用于隐藏元素是没有意义的),因此缺乏 CSS 合规性是无关紧要的。
快乐编码。
The final answer I've arrived at is "this doesn't matter." For better or worse, these tags are generated how the framework wants to generate them, and there's not a lot you can do about it other than create an HttpModule that would reformat the tags before the markup is sent to the browser.
However, it doesn't matter. Validation on these tags is irrelevant. Another developer complained that the underscores in the tag names ("__VIEWSTATE" for example) are noncompliant, as well, but it turns out that is is a CSS rule, not an HTML rule. Since no style is applied to these tags (and it wouldn't make sense to apply CSS to a hidden element) the lack of CSS compliance is irrelevant.
Happy coding.
尝试将其配置为使用 HTML 4.01,如此处所述(“旧版”环境)。
Try configuring it to use HTML 4.01 as described here ("Legacy" setting).