I have an mvc3 app which I want to write to a file but don't know how.
IIS doesn't allow StreamWriter file = new StreamWriter(Environment.CurrentDirectory);
How do I go about writing to a file?
相关问题
- Entity Framework throws exception - Network Relate
- How to make a .svc file write to asp.net Trace.axd
- How to deploy python flask application in conda ba
- ASP.NET won't compile to debug
- Slow loading first page - ASP.NET MVC
IIS allows everything. The account you are running your application under probably doesn't have permissions to write to this directory. So all you need to do is grant write permissions to this account to the specified directory. Alternatively you could write to the
~/App_Data
folder of your application where chances are that the account will have permission.You need to create a directory somewhere -- not necessarily within the InetPub -- and grant write rights for that directory to the Windows account that your Web application runs under.
So suppose your application runs in an Application Pool that is executed under the
MyApplicationUser
account. Then you would create a directory, sayD:\Writeable\MyApplication
and grantMyApplicationUser
write rights to that directory in Windows.IIS has no control over that directory, only Windows does, so that is the only place where you need to grant the write rights.