xml 文件的表单身份验证
我想知道是否可以通过 ASP.NET 3.5 中的表单身份验证来保护 xml 文件。 我有一些在线找到的许可证密钥,但除非您登录,否则您应该无法下载它们。
对于 aspx 页面,此功能会自动工作,但不适用于 xml 文件。
I was wondering if you could protect xml files through forms authentication in ASP.NET 3.5.
I have some licensekeys that are found online, but you shouldn't be able to download them unless you are logged on.
For aspx pages this works automatically but not for xml files.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将xml文件放在某个文件夹中,将web.config添加到该文件夹中,其中包含:
更改“?” (这意味着匿名用户 - 即未登录的用户)为“*”以拒绝所有用户(服务器将具有访问权限[例如通过 Server.MapPath 等])。
您可以分别扮演角色或删除此行。
另外,请考虑在 web.config 文件中您可以拒绝和允许特定扩展,如下所示:
在确定您的需求之前,请不要依赖最后一个片段。
您可以了解有关Http 处理程序的更多信息,或者查看如何:注册 HTTP 处理程序。
我还注意到有人在此处提出了类似的问题,您可能会发现它很有帮助。
希望您能尽快找到解决方案,祝您好运!
Place the xml files in a certain folder, add web.config to this folder containing:
Change the '?' (which means anonymous users - i.e. not logged in users) to '*' in order to deny all users (the server will have access [e.g. via Server.MapPath etc.]).
Respectively you can play with the roles or remove this line.
Also, consider that in the web.config file you can deny and allow specific extensions as follows:
Please don't rely on this last snippet till you make sure what are your needs.
You can find out more on Http Handlers, or take a look at How to: Register HTTP Handlers.
I also noticed someone asked a similar question here, you may find it helpful.
Hope you to find your quickly find your solution, good luck!