ASP and ActiveX control interactively fight (1)

zhaozj2021-02-16  168

tornado

Keywords: ASP, ActiveX control, digital signature, security

The ActiveX control is running on the client. We can get some information about the client, such as the IC card information, client authentication, and more. However, ActiveX controls have many disadvantages: the client's deployment is difficult, such as the client can't download correctly, download it without proper implementation, you need to set the security level of IE when downloading.

More times, I am using COM components to extend the functionality of ASP. Accurately, it is the ActiveX DLL component running in the server. Use Server.createObject ("Engineen Name. Class Name") to complete calls to components. This method is very small, as long as the components are exposed to the PUBLIC to expose both. However, sometimes we must use the ActiveX control (* .ocx) to embed the information in the web page to obtain the client. This has a lot of questions.

This is the N questions we need to solve (from simple to difficult)

1. How to get data from the server to pass to the ActiveX control.

1) Use parameters binding when initialization

2) Get data at runtime

2. The ActiveX control gets the client's information, how to pass to the server.

3. safety

1) Digital signature

2) Use the IOBJSAFE interface

Ok, let's start instance learning.

This feature demonstrates how to make a simple control and embedded in the web page.

Working environment: WinXP VB6 IE6

My IE security is set to the security level - in. All ActiveX options are set to enable.

Open VB6, create a new ActiveX control project.

Engineering Name: FOCX, User Control Name: UC1

For convenience, we use the ActiveX Control Interface Wizard ..., Menu -> Add,> Explorer -> VB 6 ActiveX Control Interface Wizard. OK.

Open ActiveX Control Interface Wizard, Next Members choose Text, next step until completion. There will be some unwanted, deleted, and the left code is as follows:

Option expedition

'note! Don't delete or modify the following is commented!

'MappingInfo = txtinfo, txtinfo, -1, text

Public property get getInfo () AS STRING

GetInfo = txtinfo.text

End Property

Public property let getinfo (Byval new_getinfo as string)

TXTINFO.TEXT () = new_getinfo

PropertyChanged "getInfo"

End Property

'Load the attribute value from the memory

Private sub UserControl_readproperties (Propbag As Propertybag)

Txtinfo.text = propbag.readproperty ("getInfo", "text1")

End Sub

'Write the attribute value to the memory

Private sub UserControl_WriteProperties (Propbag As Propertybag)

Call Propbag.writeProperty ("getInfo", txtinfo.text, "text1")

End Sub

OK, ok, we compile into a Focx.ocx file, then F5 is running directly, VB will open a test page. As follows: E: / Program Files / Microsoft Visual Studio / VB98 / UC1.HTML

At the same time, open your IE browser, see it, what you do is in this test page.

You can open the test page, you can see CLSID, such as: 890D1028-298B-45CF-9A64-6ED5A5BACBC9

Since the VB is compiled, registration has been completed. So you can't simulate the prompt that the client does not appear when the control is installed.

We continue

Use Regsvr32 f: /9cbs_vb/com _activex/sample1/focx.ocx -u uninstall

or

Open the registry, found under HKEY_CLASES_ROOT / CLSID

890D1028-298B-45CF-9A64-6ED5A5BACBC9 items, deleted, of course, this approach has an item without deleting clean.

At this point, navigate to http: //yang/uc1.htm, because the ActiveX set in IE is set to start, so the control will be displayed.

Where did the OCX have been downloaded???

Open this directory (possibly different) E: /Windows.0/downloadlined Program Files, see it, Focx.uc1 files in this directory.

Principle: After the client downloads the control, it is automatically registered, then put it in the above directory. At this time, we can open the registry to see CLSID, huh, huh, or the previous one.

We can check the properties of Focx.uc1 to see related content, which shows all files relying on the OCX. So, your OCX minimizes controls using advanced controls or third-party controls, otherwise, some problems have been downloaded. .

If the options for ActiveX on the IE are set to disabled, the browser will have a dialog box "The current security settings are forbidden to run the ActiveX control in the page. Therefore, the page may not be displayed correctly, this is required to handle other ways. .

General User's default is disabled an ActiveX option, so letting users set themselves less appropriate.

Last continued

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

New Post(0)