“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------对路径“~/upload/newspic/”的访问被拒绝。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.UnauthorizedAccessException: 对路径“~/upload/newspic/”的访问被拒绝。 ASP.NET 未被授权访问所请求的资源。请考虑授予 ASP.NET 请求标识访问此资源的权限。ASP.NET 有一个在应用程序没有模拟时使用的基进程标识(通常,在 IIS 5 上为 {MACHINE}\ASPNET,在 IIS 6 上为网络服务)。如果应用程序正在通过 <identity impersonate="true"/> 模拟,则标识将为匿名用户(通常为 IUSR_MACHINENAME)或经过身份验证的请求用户。 要将 ASP.NET 访问权限授予某个文件,请在资源管理器中右击该文件,选择“属性”,然后选择“安全”选项卡。单击“添加”添加适当的用户或组。突出显示 ASP.NET 帐户,选中所需访问权限对应的框。源错误:
行 251: public string UploadPicGetSLT(HttpPostedFile file, string filepath, int smallwidth, int smallheight)
行 252: {
行 253: Directory.CreateDirectory(filepath);
行 254:
行 255: string sss = string.Empty;
源文件: e:\IIS\App_Code\PicUpload.cs 行: 253 堆栈跟踪:
[UnauthorizedAccessException: 对路径“~/upload/newspic/”的访问被拒绝。]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +2013971
System.IO.Directory.InternalCreateDirectory(String fullPath, String path, DirectorySecurity dirSecurity) +2709968
System.IO.Directory.CreateDirectory(String path, DirectorySecurity directorySecurity) +150
System.IO.Directory.CreateDirectory(String path) +6
PicUpload.UploadPicGetSLT(HttpPostedFile file, String filepath, Int32 smallwidth, Int32 smallheight) in e:\IIS\App_Code\PicUpload.cs:253
News_NewsAdd.Button1_Click(Object sender, EventArgs e) in e:\IIS\News\NewsAdd.aspx.cs:53
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:2.0.50727.42; ASP.NET 版本:2.0.50727.42
--------------------------------------------------------------------------------对路径“~/upload/newspic/”的访问被拒绝。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.UnauthorizedAccessException: 对路径“~/upload/newspic/”的访问被拒绝。 ASP.NET 未被授权访问所请求的资源。请考虑授予 ASP.NET 请求标识访问此资源的权限。ASP.NET 有一个在应用程序没有模拟时使用的基进程标识(通常,在 IIS 5 上为 {MACHINE}\ASPNET,在 IIS 6 上为网络服务)。如果应用程序正在通过 <identity impersonate="true"/> 模拟,则标识将为匿名用户(通常为 IUSR_MACHINENAME)或经过身份验证的请求用户。 要将 ASP.NET 访问权限授予某个文件,请在资源管理器中右击该文件,选择“属性”,然后选择“安全”选项卡。单击“添加”添加适当的用户或组。突出显示 ASP.NET 帐户,选中所需访问权限对应的框。源错误:
行 251: public string UploadPicGetSLT(HttpPostedFile file, string filepath, int smallwidth, int smallheight)
行 252: {
行 253: Directory.CreateDirectory(filepath);
行 254:
行 255: string sss = string.Empty;
源文件: e:\IIS\App_Code\PicUpload.cs 行: 253 堆栈跟踪:
[UnauthorizedAccessException: 对路径“~/upload/newspic/”的访问被拒绝。]
System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +2013971
System.IO.Directory.InternalCreateDirectory(String fullPath, String path, DirectorySecurity dirSecurity) +2709968
System.IO.Directory.CreateDirectory(String path, DirectorySecurity directorySecurity) +150
System.IO.Directory.CreateDirectory(String path) +6
PicUpload.UploadPicGetSLT(HttpPostedFile file, String filepath, Int32 smallwidth, Int32 smallheight) in e:\IIS\App_Code\PicUpload.cs:253
News_NewsAdd.Button1_Click(Object sender, EventArgs e) in e:\IIS\News\NewsAdd.aspx.cs:53
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +105
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +107
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102
--------------------------------------------------------------------------------
版本信息: Microsoft .NET Framework 版本:2.0.50727.42; ASP.NET 版本:2.0.50727.42
由于在iis 6.0中,默认的应用程序池中的标示用的是Network Service,
所以在进程中是使用Network Service这个帐号运行来运行w3wp.exe进程,
而当我们在运行VS 2003的时候需要对某一个目录下进行读写操作,
看了一下该文件夹,发现没有Network Service,添加上该账号,同时选上FULL CONTROL,问题解决,\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\解决方案二
在IIS6.0中的默认应用程序池-->属性-->标示中把Net Service改成Local System该问题也可以解决。############################################################
ASP.NET 访问权限授予某个文件,请在资源管理器中右击该文件,选择“属性”,然后选择“安全”选项卡。单击“添加”添加适当的用户或组。突出显示 ASP.NET 帐户,选中所需访问权限对应的框。
右键添加net work,net services权限