0

XML形式でリクエストをWebサーバーに送信するWebクライアントがあります。Webサーバーは(かなり大きな)ファイルを作成し、それをキャッシュされたディレクトリに保存して、応答ストリームを介してWebクライアントに返します。これは、最初の数回は正常に機能しましたが、突然機能しなくなり、次の例外(XMLでラップ)が報告されました。

<error type="System.Security.SecurityException">
  <message>Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.</message>
  <stack-trace><![CDATA[   at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
   at System.Security.CodeAccessPermission.Demand()
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode)
   at Ionic.Zip.SharedUtilities.CreateAndOpenUniqueTempFile(String dir, Stream& fs, String& filename)
   at Ionic.Zip.ZipFile.get_WriteStream()
   at Ionic.Zip.ZipFile.Save()
   at Ionic.Zip.ZipFile.Save(String fileName)
   at MyApplication.UpdateItemFiles.GetUpdateContent(XDocument a_xManifest, Stream[] a_arrExtraContent) in C:\Software\MyApplication\Alpha\Web Interface\UpdateItemFiles.aspx.cs:line 265
   at MyApplication.UpdateItemFiles.Page_Load(Object sender, EventArgs e) in C:\Software\MyApplication\Alpha\Web Interface\UpdateItemFiles.aspx.cs:line 31]]></stack-trace>
</error>

コードアクセスセキュリティについてはよくわかりません。私はEverybodyにディレクトリの完全な制御を与えることさえ試みました。これは開発サーバーであり、パブリックマシンではないため、これは問題ではありません。なぜこれが最初の数回は機能するのかわかりませんが、今は機能を停止します。

サーバーとクライアント(同じマシン)の両方にWindows764ビットでVisualStudio2008を使用しています。IIS7.0と.NetFramework3.5を使用しています。

編集済み2010/12/1316:05EST:

CodeplexのDotNetZipライブラリを使用しているため、このエラーが発生します。IISまたは私の構成にアセンブリを追加する方法はありますか?

4

3 に答える 3

1

Rather than modify the security settings of your ASP.NET application's user itself, I'd suggest creating a new file access application (maybe Windows service accessible via remoting, maybe WCF), that does the file access. This application can run using the context it needs for file access.

The ASP.NET application only needs to be able to talk to the file access application. This way, your concerns are separated out, security is stronger, and you don't have to worry about what account the ASP.NET app is using, or impersonating users, etc.

于 2010-12-13T18:56:47.310 に答える
1

あなたのウェブサイトを実行しているユーザーは、デフォルトで非常に最小限の権限しか持っていないためです。あなたの最善の策は

  1. SQL へのアクセス、特定のフォルダーなど、必要な特権だけを持つ新しいユーザーを作成します。
  2. そのユーザーとして実行するようにアプリケーションを設定します
  3. web.config で偽装を有効にする

こうすることで、privs への変更をアプリのローカルに保持し、デフォルト ユーザーと同じサーバー上で実行されている他のアプリケーションからのセキュリティの問題を回避できます。

于 2010-12-13T18:51:57.343 に答える
0

Iconic.Zip問題は、 Zip アーカイブの作成に使用していたアセンブリにありました。IIS サーバーはそれを信頼していなかったため、コード アクセス セキュリティ チェックに合格していませんでした。私の解決策は、自分のコード内からストリームを作成することでした。これの欠点は、ZipFileタイプが一度にすべての読み取りと書き込みを行うため、アーカイブを保存するまでストリームを開いたままにしなければならなかったことです。

于 2010-12-15T14:06:48.100 に答える