“Value does not fall within the expected range” issue (Solved)

IIS applications run on application pools. Application pools receive requests and process them based on the settings defined. One of the settings is application pool identity. This is the account that runs application pool and perform required tasks. You may come across to this error message while trying to set a custom account as application pool identity: “Value does not fall within the expected range.

This error occurs only if you are specifying a custom account and not using any predefined accounts such as ApplicationPoolIdentity or NetworkService.

The exact error message:

There was an error while performing this operation. Details: Value does not fall within the expected range.

Read More

Access to the path is denied (Solved)

“Access to the path is denied” error is one of the most common issues ASP.NET developers come across while working with network resources in their applications. There is no straightforward solution to this problem. However, there are several things you should check to solve it.

Server Error in ‘/’ Application.
Access to the path X 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 is denied" error message
“Access to the path is denied” error message

Looking for best practices for session state and cookies in ASP.NET applications? Check this post out.

Solution for “Access to the path is denied” error

The root cause is that the application pool which is hosting your web application is not able to access to the shared folder you specified in your code. Therefore, it throws “Access to the path is denied” message.

Go through the recommendations below to find out why the application pool can’t access to the network resource.

  • Did you give “Security” and “Sharing” permissions to the application pool identity? Make sure the account has required permissions in both tabs.
Permissions to solve "Access to the path is denied" error
First step is to check permissions in “Security” and “Sharing” tabs

If there is no “Sharing” tab:

– Open Registry Editor (Start > Run > regedit)
– Take a backup of Registry (File > Export) to an external storage
– Find HKEY_CLASSES_ROOT\Directory\shellex\PropertySheetHandlers\Sharing
If the folder does not exist, create it.
– There should be a (Default) value with type REG_SZ and Data {f81e9010-6ea4-11ce-a7ff-00aa003ca9f6}
The Data is blank? Double click on it and paste in {f81e9010-6ea4-11ce-a7ff-00aa003ca9f6}

The “Sharing” tab is still not displayed? Go to “Folder Options“. Check “Use Sharing Wizard (Recommended)

Still not displayed? In regedit, find HKLM\System\CCS\Control\Lsa\forceguest. Modify the forceguest entry value to 0

  • Is impersonation enabled? In order to check it: “IIS Manager > Server name > Sites > Site name > Authentication > ASP.NET Impersonation”. If impersonation is enabled, impersonated user(s) will need permission on the shared folder.
  • Do you have a virtual directory? If any virtual directories are used, please make sure they use application pool identity account in their pass-through authentication settings.

More to consider

  • After making changes to application pool identity, please make sure to recycle , stop, and then start the application pool.
  • Are you able to open the shared folder in your web server by using the credentials of application pool identity account? Check it: “Start > Run > \\server-name\shared-folder”.
  • In the server that hosts the shared folder, check for failed logon attempts to see which user was used to access to shared folder. In order to check it: “Start > Event Viewer > Windows Logs > Security > Audit Failure“.
Event viewer to identify the cause of "Access to the path is denied" error
Find out which account is used to access to the network resource

Are you using ApplicationPoolIdentity to run your application pools? In this case, you should give permission to COMPUTER$ account on the network resource.

In conclusion, your effort to solve this problem should focus on the application pool identity account and shared folder permission. If you are still not able to solve the problem, please leave a comment here.

References