Summary of solutions for access denied by ASP. NET to Path & quot; xxxxx & quot;

Source: Internet
Author: User

In windows 2003, when running a web application, the following error occurs:
The server cannot process the request. --> access to the path "C:/temp/mytest.txt" is denied.
Note: An unhandled exception occurs during the execution of the current Web request. Check the stack trace information for details about the error and the source of the error in the code.

Exception details: System. UnauthorizedAccessException: Access to path "D:/temp1/MyTest.txt" is denied.

Solution 1

Add the Network Service account to the directory for read/write operations. Because in iis 6.0, the default application pool uses Network Service, therefore, the Network serviceaccount is used to run the w3wp.exe process in the process. When we run VS 2003, we need to perform read and write operations under a directory. After reading this folder, we find that there is no Network Service, add the account and select "full control" to solve the problem.
Specific process: Right-click the folder and choose Properties> Security> Add> advanced> search now. Select "network service" under "Search Results"> OK

Solution 2

In IIS6.0, change the default application pool --> properties --> label to "Local System". This problem can also be solved.

What is an application pool? This is a brand new concept of Microsoft: The application pool is a configuration that links one or more applications to one or more worker processes. Because applications in the application pool are separated from other applications by working process boundaries, applications in an application pool will not be affected by problems caused by applications in other application pools.

Windows 2003 supports two working modes at the same time. The default is ISS 6.0 Working Process Isolation Mode. Working Process Isolation Mode prevents one application or site from being stopped and affects another application or site, greatly enhancing the reliability of IIS. So how to set two working modes?

Start IIS manager, right-click the website, and select "properties" to open the Properties dialog box (figure 1 ). In IIS 6.0 Working Process Isolation Mode, all application code runs in the isolation environment. How are they isolated? In Windows 2003, an application pool is added. The working process isolation mode allows you to create multiple application pools. Each application pool can have different configurations. Because these application pools receive their requests directly from the kernel rather than the WWW Service, the performance and reliability are enhanced. To isolate Web applications running on the same computer but belonging to different websites, you need to create a separate application pool for each website.

Create application pool

In IIS manager, open the local computer, right-click application pool, and choose new application pool (the application pool can be created only in Working Process Isolation Mode ). In the application pool Name box, enter a new application pool name. If the ID (for example, AppPool #1) that appears in the "application pool ID" box is not what you want, you can rename it. If you click "use existing application pool as template", right-click the application pool you want to use as the template in the "application pool name" box. Click [OK].

Assign application pool

In IIS manager, right-click the application for which you want to assign an application pool, and then click Properties ". Click the "home directory" tab to confirm whether the "Application name" of the directory or virtual directory you are assigning has been filled in. If the "Application name" box is not yet filled, click "CREATE" and enter a name.

In the application pool list box, select the name of the application pool you want to assign to it. Click [OK].

I have found a lot of information on the Internet. There are several solutions:

1. The installation may be faulty. reinstall and run the command aspnet_regiis-I. Remember to start it.
2. Upgrade everyone permission to modifiable
3. Improve the aspnet permission: Control Panel-management tools-Computer Management-local users and groups to find the ASPNET affiliated to add the Administrators
4. Delete the iis virtual directory and recreate it.
5. Add <identity impersonate = "true"/> to the web. config file.
6. To grant ASP. NET write access to a file, right-click the file in resource manager, select "properties", and select the "Security" tab. Click Add to add an appropriate user or group. Highlight the ASP. NET account and select the corresponding access permission box.

Everyone plus write permission
7. Use an xml file to save the system option settings, write data with asp.net, and debug and run (ctrl + F5) normally. After the website is configured, the following error occurs: "Access to path xxx. xml is denied ". Resource Manager-> Tools-> Folder Options-> check if "use simple file sharing" is not selected, right-click the xml file, select "attribute", click "security", and add "aspnet ", select "full control.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.