对 IIS 上托管的 WCF 服务进行 wwwroot 之外的目录访问
我一直在开发当前托管在 IIS 上的 WCF 服务。我需要让 WCF 服务访问 wwwroot 文件夹之外的目录。
我是否正确地假设 wwwroot 之外的目录访问仅限于 IIS 上托管的 WCF 应用程序,因为它会限制于 IIS 上托管的 ASP.Net 应用程序?
如果是这种情况,允许 WCF 服务访问 wwwroot 之外的设置文件夹的最安全方法是什么?
顺便说一句 - 我正在混合传输模式下运行,而不是 ASP.Net 兼容模式。
I've been working on a WCF service that is currently hosted on IIS. I need to get the WCF service to access a directory outside of the wwwroot folder.
Am I right in assuming that directory access outside of wwwroot is restricted to WCF apps hosted on IIS as it would be restricted for an ASP.Net application hosted on IIS?
If this is the case, what is the safest way of allowing the WCF service to acccess a set folder outside of the wwwroot?
BTW - I'm running in Mixed Transports Mode, not ASP.Net compatibility mode.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
文件访问将根据托管您的服务的应用程序池的标识受到限制。您的服务将能够访问应用程序池标识有权访问的任何文件,无论该文件是否位于 IIS 网站的根目录中。如果您想使用诸如 Server.MapPath 之类的相对路径来访问网站根目录中的文件,那么您必须在 ASP.Net 兼容模式下运行 WCF 服务。有关采用 ASP.Net 兼容模式的 WCF 的详细信息,请参阅以下页面:
http:// msdn.microsoft.com/en-us/library/aa702682.aspx
File access is going to be limited based on the identify of the application pool that is hosting your service. Your service will be able to access any file the application pool identity has access to whether it is in the root of your IIS website or not. If you want to access files within the root of your website using relative paths with something like Server.MapPath then you'll have to run your WCF service in ASP.Net compatability mode. See the following page for details on WCF with ASP.Net compatability mode:
http://msdn.microsoft.com/en-us/library/aa702682.aspx
我认为最好的方法是为您的服务创建另一个应用程序池,并分配一个专门创建的帐户作为新应用程序池的标识。然后将帐户所需的权限授予您需要访问的文件夹和文件。如果您想使用相对路径引用外部文件夹,则可以将其设置为站点的虚拟目录。
I think that the best approach is to create another application pool for your service and assign a specially created account as the identity of your new application pool. Then give the needed permissions of the account to the folders and file you need to access. You can make the external folder a virtual directory of the site if you want to reference it with a relative path.