Talk about the permission configuration of the ASP.NET virtual host! (Reproduced)

xiaoxiao2021-03-06  40

In actual applications, we have found that there are many ASP.NET space providers without relevant experience, while still staying in the management mode of ASP. The most common, the configuration of the directory permissions: most of them take the experience of the ASP, give the user to all permissions, and then remove the relevant permissions of the disk root directory. This will result in a problem, which is the server.mappath in the ASP.NET. This method is not required to create a directory or file, as creating the code below: Directory.createdIRectory (Server.MAppath ("MyDirectory) This is a very simple operation: Create a subdirectory called "MyDirectory" in the user's current directory. Then, such an operation will not be able to run without the correct configured space, it will prompt this error: unfounded part of the path "D: /". (The D: / may be other drives) Why have this error? The reason is the method of server.mappath (), this method is to let a relative path to an absolute path, and in the process of conversion, the .NET framework needs to get some properties of the current hard disk, such as the tray, etc., at this time, Space providers reject all .NET users all rejected the permissions of the root directory of the disk, resulting in the process that the program cannot run normally. At one time, the space provider said: "Why do you want to use an absolute path, don't use a relative path?" This is not good, if you do this: Directory.createDirectory ("MyDirectory); system is running It is not like you imagined, automatically creates a directory in the user's current directory, and try to create a directory under the C: / WinNT / System32 path (where C: / WinNT means your operating system installation. path)

转载请注明原文地址:https://www.9cbs.com/read-74158.html

New Post(0)