Solution: Principle: The page (related to IIS) has a lower permission than the DLL running permission. It is estimated that Microsoft is designed to take into account what hackers will exploit this vulnerability. You only need to obtain this value before running the page. The complete code is as follows: /// <summary> /// obtain cpuid /// </Summary> /// <returns> </returns> Public static string getcpuid () {string cpuid = NULL; managementclass mclass = new managementclass ("win32_processor"); try {managementobjectcollection MOC = mclass. getinstances ();
Foreach (managementobject Mo in MoC) {cpuid = Mo. properties ["processorid"]. value. tostring (); break;} catch (exception ex) {cpuid = ex. tostring ();} If (system. web. httpcontext. current. application ["cpuid"] = NULL) {system. web. httpcontext. current. application. lock (); system. web. httpcontext. current. application ["cpuid"] = cpuid; system. web. httpcontext. current. application. unlock ();} return cpuid ;}
On the page, call the cpuid value: system. web. httpcontext. current. application ["cpuid"]. tostring (); the premise of running is that the Code must be run before the page is executed, for example, the code is executed first in the httpmodules program.
Finally, paste the running effect:
-------------- The page starts before calling ------------ cpuid value: bfebfbff00000f29 -------------- the page ends before calling --------------
-------------- Page call
Start with -------------- cpuid value: system. management. managementexception: access is denied in system. management. managementexception. throwwithextendedinfo (managementstatus errorcode) in system. management. managementscope. initializeguts (Object O) in system. management. managementscope. initialize () in system. management. managementobject. initialize (Boolean GetObject) in system. management. managementclass. getinstances (enumerationoptions options) in system. management. managementclass. getinstances () in managementtest. class1.getcpuid () -------------- page call ends --------------