私はVS2010で完璧に動作するC#Webアプリケーションを持っていますが、IIS7サーバーに展開すると「画像が見つかりません」アイコンが返されます。FileNotFoundException IIS7
問題のコードの一部は、本質的に操作した後、ウェブページへのうち押し戻さ、ネットワーク共有の場所に画像のサムネイルをつかみます。
Webサーバーは、アクセスしようとしているファイルと同じネットワーク上にあります。このWebページにアクセスするすべてのユーザーは、すべて同じイントラネット上にあります。
アプリケーションは、1つの方法または別に分類されているネットワーク保存されたリソースの格納されたリストです。
私はアプリケーションをデプロイする場合、それは私が私のアプリケーションログで見つける上記の2つのエラーを与えます。私はこれがファイルアクセス許可エラーで、2つのエラーがリンクされていると感じていますが、アプリケーションを正しく動作させるためのアクセス許可を変更する場所がわかりません。
Exception information:
Exception type: FileNotFoundException
Exception message: T:\Published\Generic.jpg
しかし、「T:\ Published \ Generic.jpg」をIEのアドレスバーに差し込むと、画像をロードします。
画像を処理するコードのセクションでは、このです:
System.Drawing.Image img;
img = System.Drawing.Image.FromFile(MapPath(Request.QueryString["File"].ToString()));
Iを有するとMapPathメソッド無しの両方でそれを試してみました。
私は、アプリケーションをデバッグしようとするが、それはVS2010で働いているので、それはそれは、IISサーバー上で翻弄されている理由私は知らない例外がスローされていません。
全体のスタックトレース要求通り:imagedrawer.aspxの
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 13/02/2012 4:16:26 PM
Event time (UTC): 13/02/2012 11:16:26 PM
Event ID: 1f01693f71a2443790a8d83ba06a88a4
Event sequence: 12
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/2/ROOT-3-129736485835718008
Trust level: Full
Application Virtual Path:/
Application Path: C:\inetpub\wwwroot\
Machine name: XXXXXX
Process information:
Process ID: 10768
Process name: w3wp.exe
Account name: IIS APPPOOL\ASP.NET v4.0
Exception information:
Exception type: FileNotFoundException
Exception message: T:\Published\Generic.jpg
at System.Drawing.Image.FromFile(String filename, Boolean useEmbeddedColorManagement)
at imagedrawer.Page_Load(Object sender, EventArgs e)
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Request information:
Request URL: http://localhost/imagedrawer.aspx?File=T:\Published\Generic.jpg
Request path: /imagedrawer.aspx
User host address: ::1
User:
Is authenticated: False
Authentication Type:
Thread account name: IIS APPPOOL\ASP.NET v4.0
Thread information:
Thread ID: 64
Thread account name: IIS APPPOOL\ASP.NET v4.0
Is impersonating: False
Stack trace: at System.Drawing.Image.FromFile(String filename, Boolean useEmbeddedColorManagement)
at imagedrawer.Page_Load(Object sender, EventArgs e)
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Custom event details:
内容:
System.IO.MemoryStream ms = new System.IO.MemoryStream();
System.Drawing.Image img;
img = System.Drawing.Image.FromFile(MapPath(Request.QueryString["File"].ToString()));
if (img.Height > 80 || img.Width > 80)
{
System.Drawing.RectangleF RF = new System.Drawing.RectangleF();
RF.X = 0;
RF.Y = 0;
RF.Height = (img.Height < 80) ? img.Height : 80;
RF.Width = (img.Width < 80) ? img.Width : 80;
System.Drawing.Bitmap bmthumb = (System.Drawing.Bitmap)img.Clone();
System.Drawing.Bitmap bmCrop = bmthumb.Clone(RF, bmthumb.PixelFormat);
img = (System.Drawing.Image)bmCrop;
}
img.Save(ms, System.Drawing.Imaging.ImageFormat.Png);
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + Request.QueryString["File"].ToString());
Response.AddHeader("Content-Length", ms.ToArray().Length.ToString());
Response.ContentType = "image/jpeg";
Response.BinaryWrite(ms.ToArray());
Response.End();
img.Dispose();
@ JKM、IEを使用して共有にアクセスすると、IEはあなたの資格情報を使用します。 IEが動作している場合、シェアにアクセスする権利があることがわかります。しかし、IIS/ASP.NET上のアプリケーションはアプリケーションプールID(Guvante氏のように)で実行されているため、プールIDがその共有にアクセスできないことを示します(UNCパスを使用する必要があります。 support.microsoft.com/kb/257174)。共有にアクセスするためのプールIDの許可を与えるか、共有にアクセスできるアカウントにプールのIDを変更する必要があります。次回は、ユーザーのコンテキストにもっと注意を払ってください。 –
対象のマシンにソリューションを展開し、正しいアプリケーションプールサービスを設定すると、このエラーは登録されなくなりました。 – Sorean