简体   繁体   English

从IIS中托管的WCF服务访问文件系统

[英]Accessing the file system from a WCF service hosted in IIS

I have the need to read and write files on the server file system from within a WCF service hosted in IIS. 我需要从IIS托管的WCF服务中读取和写入服务器文件系统上的文件。 This service is called via a Silverlight 4 application and RIA services. 通过Silverlight 4应用程序和RIA服务调用此服务。 The file paths can be fixed to a known location on the server but we are having issues getting passed security issues and continue to get "Access Denied" errors. 可以将文件路径固定到服务器上的已知位置,但是在传递安全性问题方面仍然存在问题,并且继续出现“访问被拒绝”错误。 The application itself uses Forms Authentication and the web server is configured for anonymous access. 该应用程序本身使用表单身份验证,并且将Web服务器配置为匿名访问。

We haven't gotten passed this issue in our development environment and I'm assuming that in production we can specify a specific account in IIS to host the site under and then grant that account specific rights to the file system. 我们尚未在开发环境中解决此问题,我假设在生产中,我们可以在IIS中指定一个特定帐户来托管网站,然后将该帐户授予文件系统特定权限。 In development using the VS 2010 development web server what are our options? 在使用VS 2010开发Web服务器进行开发时,我们有哪些选择?

Our goal is to do something as simple as creating new files or deleting files from a known path on the server (ie "C:\\Temp\\") from within a method call to the WCF service. 我们的目标是做一些简单的事情,例如从WCF服务的方法调用中创建新文件或从服务器上的已知路径(即“ C:\\ Temp \\”)删除文件。 it's acceptable that it even be a temp folder underneath the virtual directory. 甚至可以是虚拟目录下的临时文件夹。

Your best option here: don't use the dev server for this; 最好的选择是:不要为此使用dev服务器; use IIS. 使用IIS。 Fighting tooling issues in something unrelated to what you are trying to do is a waste of time, so try to mimic your deployment environment as closely as possible. 在与您要执行的操作无关的事情中解决工具问题是浪费时间,因此请尝试尽可能地模仿您的部署环境。

You might also be able to use IISExpress for this, but since you know you already have nuances, I'd just go the whole-hog and use IIS. 您也许还可以使用IISExpress,但是由于您已经知道细微差别,所以我将全力以赴并使用IIS。 This also lets you hone the deployment process, which is a dev task. 这也使您可以完善部署过程,这是一个开发任务。

Once setup, just create an app-pool and associate it with new account (not your account, unless it is going to be your account in production). 设置完成后,只需创建一个应用程序池并将其与新帐户关联(而不是您的帐户,除非它将成为您的生产帐户)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM