What is the difference between the master thread and sub-thread permissions in Asp.net? Can a sub-thread have the same permissions as the master thread?

Source: Internet
Author: User
Tags hosting web hosting

We are at ASP. . NET web hosting websites use multithreading technology. But there is a problem:

The main web page thread has the read and write permissions on the file, but the new thread does not have the permission.
For exampleCode: Create a file in the main thread and the new thread respectively. The execution result is that the file is successfully created by the main thread, and the sub-thread has an operation error: no permission to create the file. What is going on here? How can we avoid this situation? Thank you.

 

Code

We are at ASP. . NET web hosting websites use multithreading technology. But there is a problem:

The main web page thread has the read and write permissions on the file, but the new thread does not have the permission.
For example, use the following code: create a file in the main thread and the new thread respectively. The execution result is that the file is successfully created by the main thread, and the sub-thread has an operation error: no permission to create the file. What is going on here? How can we avoid this situation? Thank you.

< Script runat = " Server " >
Protected   Void Page_load ( Object Sender, eventargs E)
{
System. Io. file. writealltext (server. mappath ( " /114/B "   + Datetime. Now. millisecond. tostring

()),"Dd");
Response. Write (application ["E"]);

System. Threading. thread t= NewSystem. Threading. Thread (NewSystem. Threading. threadstart

(Dd ));
T. Start ();

Response. End ();
}
Private   Void Dd ()
{
Try
{
System. Io. file. writealltext (server. mappath ( " /114/ "   +  

Datetime. Now. millisecond. tostring ()), " Dd " );
}
Catch (Exception E)
{
Application [ " E " ] = E. Message + E. helplink + E. Source + E. stacktrace + E. targetsite;
}
}

</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.