September 26, 2004

access to the path is denied

For solve below problem you can go to C:\Inetpub\wwwroot\[Project Name] and select your file and then right click on that (your file) and select properties from menu.After that you can go to Security tab page and select Users([your computer name]\Users) from "Group or user names" and then check the "Write" at the "Permissions for Users". I hope this helps.
Server Error in '/Project01' Application.
Access to the path "c:\inetpub\wwwroot\Project01\?????.xml" is denied.
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.UnauthorizedAccessException: Access to the path "c:\inetpub\wwwroot\Project01\?????.xml" is denied.
ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via <identity impersonate="true"/>, the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.
To grant ASP.NET write access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
Source Error:
Line 79: // Write the new DataSet with the new name and password to the XML file.
Line 80: fs = new FileStream(Server.MapPath("?????.xml"), FileMode.Create, FileAccess.WriteFileAccess.Read);
Line 81: StreamWriter writer = new StreamWriter(fs);
Line 82: ds.WriteXml(writer);
Source File: c:\inetpub\wwwroot\Project01\adduser.aspx.cs Line: 80
Stack Trace:
[UnauthorizedAccessException: Access to the path "c:\inetpub\wwwroot\Project01\?????.xml" is denied.]
System.IO.__Error.WinIOError(Int32 errorCode, String str) +393
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync, String msgPath, Boolean bFromProxy) +888
System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access) +43
Project01.adduser.Signup_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\Project01\adduser.aspx.cs:80
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277
Version Information: Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573
خب این بار هم ASP .net ... وقتی می خواهید روی یک فایل چیزی رو بنویسید ایراد می گیره و حتی وقتی میرید و write بودن اون رو از توی IIS تنظیم می کنید باز هم Error می ده و بعد از اون وقتی می رید توی C:\Inetpub\wwwroot\[Project Name]\FileName و چک می کنید که ReadOnly نباشه می بینید که همه چیز درسته ولی بازم کار نمی کنه ... احتمالا اگر نسخه Serevr ویندوز رو کامپیوترتون نصبه برای حل این مشکل کافیه کارهای زیر رو بکنید.
- دوباره برید به آدرس C:\Inetpub\wwwroot\[Project Name]\FileName و روی فایل مورد نظر RightClick کنید و Properties و سپس Tab آخر یعنی Security را انتخاب کنید.
- احتمالا تا حالا 10 دفعه اینجا اومدید و دیدید که Administator که شما باشد write ش چک شده ولی شما باید از بین لیست "Group or user names" گزینة Users([your computer name]\Users) را انتخاب کرده و در جدول پایین Write رو انتخاب کنید به همین سادگی ....

No comments: