This project is read-only.

error creating directory

Topics: User Forum
Aug 6, 2009 at 9:10 PM


I've been trying to publish my site using this kit and I am stuck with this problem. The problem is I can't update the site. I can't upload images in the gallery or upload files. My provider already set the permissions on the App_Data directory.

Here is the error displayed when I try to upload a file.

Is there any other settings that I'm missing here?


Server Error in '/' Application.

Security Exception

Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Source Error:

Line 77:                 string physicaldirectory = HttpContext.Current.Server.MapPath(virtualdirectory);
Line 78: if(!Directory.Exists(physicaldirectory))
Line 79: Directory.CreateDirectory(physicaldirectory);
Line 80: return virtualdirectory;
Line 81: }

Source File: c:\domains\\wwwroot\App_Code\Sections\DownloadList.cs    Line: 79

Stack Trace:

[SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessPermission.Demand() +59
System.IO.Directory.InternalCreateDirectory(String fullPath, String path, DirectorySecurity dirSecurity) +458
System.IO.Directory.CreateDirectory(String path, DirectorySecurity directorySecurity) +150
System.IO.Directory.CreateDirectory(String path) +6
MyWebPagesStarterKit.DownloadList.get_UploadDirectory() in c:\domains\\wwwroot\App_Code\Sections\DownloadList.cs:79
SectionControls_DownloadList.btnSaveDetails_Click(Object sender, EventArgs e) in
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) +7350
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +213
System.Web.UI.Page.ProcessRequest() +86
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
System.Web.UI.Page.ProcessRequest(HttpContext context)
ASP.default_aspx.ProcessRequest(HttpContext context) in App_Web_qjs888g9.8.cs:0
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +358
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64

Aug 7, 2009 at 12:05 PM

I would suggest modifying the web.config file to make sure your'e using the highest permission avalible for you.

setting the trust level to 'Full' would solve this issue if your hosting server allows you to do so.

looks like :

<trust level="Full" />

If you fail to set the trust level to full because the web server won't allow you to do so (which is very probable) 
I beleive that 'Medium' level also contains write permissions to the App_Data folder.

Try this and let me know
Good Luck (: