Microsoft ASP. NET site deployment guide (6): Set folder Permissions

Source: Internet
Author: User

. Overview

When you use Visual Studio's Visual Studio Development Server (Cassini) for testing, the program runs under the authorization of your system login account. Generally, the administrator account is used, in this way, it has all the permissions to do everything. However, when the program runs on IIS, its authorization is the account set by the application pool of the site. By default, this account only has read and execution permissions, the write permission is useless.

 

Generally, programs need to upload or update files, which becomes a problem. For example, in the Contoso University Program, Elmah willElmahCreate a log file in XML format. Even if you don't use a tool like Elmah, your website may need users to upload portraits.

 

In this section, the test result is that the log cannot be written before the start. After the write permission is set, you can write the file normally after the test.

 

Reminder: check the Troubleshooting page if an error message or some functions are abnormal during operations in this section.

2. Test the error logging and report functions.

Check whether the program works properly in IIS (although it is okay in VS). You can simulate an error and open the Elmah error log to check whether the error information is correctly recorded, if the XML log is not properly created, an empty report page is displayed.

 

Open the browser to access http: // localhost/ContosoUniversity and enter an invalid URL address. In this way, the system will generate a yellow page error (because the Web. the error message in config is configured with "RemoteOnly" and you are running on the local IIS, so the custom page is not displayed. aspx ):

 

Now, open Elmah. axd to view the error report. After logging in with the Administrator account ("admin"/"Pas $ w0rd"), you will see a blank record page:

 

No error reports are used, because Elmah does not successfully create an XML log file in the Elmah folder.

3. Set the write permission for the Elmah directory

You can set folder permissions manually or automatically through the deployment process. It is complex to use automated settings.MSBuildCode. Since this is only done during the first deployment, this section only shows how to grant permissions manually. (For information about automatic permission Setting, you can access: Setting Folder Permissions on Web Publish .)

 

Open the resource manager, find the directory C: \ inetpub \ wwwroot \ ContosoUniversity where your program is deployed, right-click the Elmah folder, and select Properties-installation tab:

 

(If you are in a group or user nameGroup or user namesInvisibleDefaultAppPool, You may need to install IIS and ASP on your machine. NET4 sets up an account. The account you are looking for in this chapter is the account used by the application pool used by the Contoso University Program, and then adds it and gives the write permission. For information about application pool authentication, you can view the connections at the bottom of the page .)

Click to editEdit, InPermissions for ElmahSelectDefaultAppPoolIn (Allow) SelectWriteCheck box.

 

Click OK to close the dialog box.

4. retest the error log and report functions.

Simulate an error in the same way (access to an invalid URL address) and open the error log page. At this time, you can find that the error log is already displayed on the page.

Like SQL Compact database updatesApp_DataFolder write permission, however, because the deployment process automatically givesApp_DataSet write permissions, so we do not need to do additional work manually.

 

Now you have completed the necessary work to run the Contoso University Program on the local IIS. In the next section, we will deploy the program to the production environment of the host provider so that the program can be publicly accessed.

5. More information

In this example, the reason why Elmah cannot save logs is easy to find. You can know it by tracking IIS. For more information, see Troubleshooting Failed Requests Using Tracing in IIS 7.

 

To grant permissions to the Application Pool identity, visit: Application Pool Identities and Secure Content in IIS Through File System ACLs.

<Script type = text/javascript> if ($! = JQuery) {$ = jQuery. noConflict ();} var isLogined = false; var cb_blogId = 101461; var cb_entryId = 2263111; var cb_blogApp = "TomXu"; var cb_blogUserGuid = "Callback "; var cb_entryCreatedDate = '2017/28 12:29:00 '; </script>

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.