Solved

Invoking a DLL (ISAPI extension) method from an html FORM (via action)

Posted on 2000-03-06
8
582 Views
Last Modified: 2008-03-17
two part question:


PROBLEM BACKGROUND:

Platform: NT Server 4.0
          IIS 4
          IE 5

I copied a working ISAPI extension from Visual C++ ISAPI Programming book.  The extension worked great if the method (i.e., TestDLL.dll?Test) is invoked using anchor (<a href="http://myhost/TestDLL.dll?Test>here</a>

The method also gets invoked correctly when it is invoked via the url (i.e., typing the fully qualified url addr at the address field for IE or netscape).

However, I just can't figure out how to invoke the method using a form object (i.e., via the submit button of the html form) as such:

<form action="/scripts/TestDLL.dll?Test" method="POST" name="Testing">
  <p>Name
  </p>
  <p>
    <input type="submit" name="Submit2" value="Submit">
    <input type="reset" name="Reset2" value="Reset">
  </p>
</form>


I've tried numerous combinations of get and post and other troubleshooting to no avail.

The error i'm getting when i click on the submit button is (in netscape 4.7):

--------------------
BAD REQUEST

Your client sent a request that this server didn't understand.
Request: Test
--------------------


QUESTIONS:
1. how can I get the method to executing when the user clicks on the submit button?
2. if the method requires parameters, how can i pass those form parameters (as entered by the user) to the method?

Thank you



0
Comment
Question by:bustany
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 4

Expert Comment

by:jkunal
ID: 2590991
bustany sorry if my answer is not what you want,
but from your description it looks like the dll checks for the query string(URL).
I know of ISAPI filters doing this but not ISAPI extensions.
Is it possible in ISAPI extensions also?
0
 

Expert Comment

by:ymeng
ID: 2592745
bustany,

My understanding is that every isapi extension handles cerntain input in certain format. Some extension may accept a file, and then put the file into database. Some extension may just accept a string, and search the database and return the results to the client. I don't have your book, so I don't know exactly what testDll.dll does.

Here is my general comments:

Look in testDll.cpp (if it's in c++)
and find HttpExtensionProc(), you should see main logic there as what the program is looking for. In some cases, it looks for some predefined fields. e.g. the funciton may be looking for "FieldName1", "FieldName2". Whereas you are sending "Submit2" and "Reset2". If the program can not find the fields it is looking for, it may just return error.

One possible reason can also be your form html syntax. Some extension accepts form input using multipart format. If that's the case, you will need to add enctype="multipart/form-data" to your form.

Good luck.
0
 
LVL 3

Expert Comment

by:absong
ID: 2599252
your first line of code was:

<form action="/scripts/TestDLL.dll?Test" method="POST" name="Testing">


replace it with:

<form action="/scripts/TestDLL.dll" method="POST" name="Testing">
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:snifong
ID: 2600903
Download ftp://ftp.wrox.com/professional/664.zip . Extract it and look in the FormMail folder.  This will put you well on your way.
0
 
LVL 1

Expert Comment

by:loumf
ID: 2614686
You need to write parse map entries for your function

Look for the line that begins with  BEGIN_PARSE_MAP

That's where you define your entry point and their arguments

In your case you probably have something like:

ON_PARSE_COMMAND(Test, classname, ITS_EMPTY )

This means that Test takes no arguments

replace with something like:

ON_PARSE_COMMAND(Test, classname, ITS_PSTR)
ON_PARSE_COMMAND_PARAMS("Submit2")


Look up these macros in VC++ help for more information
0
 
LVL 1

Expert Comment

by:loumf
ID: 2615962
oh yeah, and don't forget to change the signature of the Test function from

void Test()

to

void Test(char* submit2)

0
 

Author Comment

by:bustany
ID: 2618142
I actually did all that as part of copying the sample code from the text.  I found out the reason for it not working was due to the fact that i "overloaded" Test, one without any
params, and one with two parms.  Once I renamed the second test, it worked.  So I guess in handling forms via an isapi, once can not overload methods!!! pretty bad on microsoft's side, i think.  
0
 
LVL 1

Accepted Solution

by:
loumf earned 200 total points
ID: 2619687
The problem is not really microsoft's.  The macros become expressions with pointers to functions and C++ offers no way to resolve overloads when naming them.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Grammars for C C++ and java 1 139
sorting efficency of sorting algorithm 30 132
VS2015 Redefinition errors 4 91
Autosar OS Multicore Share Resources confusion ? 2 108
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question