This project is read-only.

Server Error in '/TestBlog' Application.

Topics: ASP.NET 2.0, Business Logic Layer, Controls
Mar 30, 2010 at 7:57 AM

I am using IIS 7 on Windows 7 Platform. I have installed the application as it shows in the video. However I am getting following error at the first time run.



Server Error in '/TestBlog' Application.

Access to the path 'C:\inetpub\wwwroot\TestBlog\App_Data\datastore\extensions\AkismetFilter.xml' is denied.

Description: 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\TestBlog\App_Data\datastore\extensions\AkismetFilter.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 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:

The source code that generated this unhandled exception can only be shown when compiled in debug mode. To enable this, please follow one of the below steps, then request the URL:

1. Add a "Debug=true" directive at the top of the file that generated the error. Example:

  <%@ Page Language="C#" Debug="true" %>


2) Add the following section to the configuration file of your application:

       <compilation debug="true"/>

Note that this second technique will cause all files within a given application to be compiled in debug mode. The first technique will cause only that particular file to be compiled in debug mode.

Important: Running applications in debug mode does incur a memory/performance overhead. You should make sure that an application has debugging disabled before deploying into production scenario.

Stack Trace:

[UnauthorizedAccessException: Access to the path 'C:\inetpub\wwwroot\TestBlog\App_Data\datastore\extensions\AkismetFilter.xml' is denied.]
   System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +7716783
   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) +1162
   System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) +65
   System.IO.StreamWriter.CreateFile(String path, Boolean append) +62
   System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize) +58
   System.IO.StreamWriter..ctor(String path) +30
   BlogEngine.Core.Providers.XmlBlogProvider.SaveToDataStore(ExtensionType exType, String exId, Object settings) in C:\Data\Development\BlogEngine.NET\BlogEngine\DotNetSlave.BusinessLogic\Providers\XmlProvider\DataStore.cs:71
   BlogEngine.Core.Providers.BlogService.SaveToDataStore(ExtensionType exType, String exId, Object settings) in C:\Data\Development\BlogEngine.NET\BlogEngine\DotNetSlave.BusinessLogic\Providers\BlogService.cs:368
   BlogEngine.Core.DataStore.ExtensionSettingsBehavior.SaveSettings(ExtensionType exType, String exId, Object settings) in C:\Data\Development\BlogEngine.NET\BlogEngine\DotNetSlave.BusinessLogic\DataStore\ExtensionSettingsBehavior.cs:37
   ExtensionManager.SaveToStorage() in C:\Data\Development\BlogEngine.NET\BlogEngine\DotNetSlave.BusinessLogic\Web\Extensions\ExtensionManager.cs:406
   ExtensionManager.SaveSettings(String extensionName, ExtensionSettings settings) in C:\Data\Development\BlogEngine.NET\BlogEngine\DotNetSlave.BusinessLogic\Web\Extensions\ExtensionManager.cs:341
   BlogEngine.Core.CommentHandlers.InitCustomFilters() in C:\Data\Development\BlogEngine.NET\BlogEngine\DotNetSlave.BusinessLogic\CommentHandlers.cs:326
   BlogEngine.Core.CommentHandlers.Listen() in C:\Data\Development\BlogEngine.NET\BlogEngine\DotNetSlave.BusinessLogic\CommentHandlers.cs:28
   BlogEngine.Core.Utils.LoadExtensions() in C:\Data\Development\BlogEngine.NET\BlogEngine\DotNetSlave.BusinessLogic\Utils.cs:551
   ASP.global_asax.Application_Start(Object sender, EventArgs e) +5

[HttpException (0x80004005): Access to the path 'C:\inetpub\wwwroot\TestBlog\App_Data\datastore\extensions\AkismetFilter.xml' is denied.]
   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +2721530
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +128
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +188
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +295
   System.Web.HttpApplicationFactory.GetPipelineApplicationInstance(IntPtr appContext, HttpContext context) +56
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +231

[HttpException (0x80004005): Access to the path 'C:\inetpub\wwwroot\TestBlog\App_Data\datastore\extensions\AkismetFilter.xml' is denied.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8897659
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +85
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +333

Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927


What is my solution to resolve the error? Please help me.

Thank you,

Mar 30, 2010 at 9:53 AM

It's required to have Write permissions set on the App_Data folder within BE.  You might want to make sure Write permissions are set.

If the blog is on your own computer, then you can probably just give all Users (or Everyone) full permissions on the App_Data directory.  Permissions can be given by right-clicking on the App_Data folder and going to the Security tab.

Nov 2, 2010 at 2:08 AM

I was having the same problem on Windows Server 2008 R2. What I found was that at some point the default Identity for the application pools were changed from Network Service to Application Pool Identity. So I had to grant write permission to the specific application pool that BlogEngine.NET runs in. In the permission dialog type IIS APPPOOL\{AppPoolName} (for example IIS APPPOOL\Classic .NET AppPool). Once the correct user had write permission, I no longer recieved the error.