简体   繁体   中英

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. This service is called via a Silverlight 4 application and RIA services. 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.

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. In development using the VS 2010 development web server what are our options?

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. 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; use 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. 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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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