HTTP Post to Domino agent from .NET form

This would seem pretty straight forward, but I cannot seem to get this to work. I have a .NET aspx page and I want to perform an HTTP POST to a Domino script agent. My ASPX page is simple for right now:

<%@ Page Language=“C#” AutoEventWireup=“true” CodeFile=“Default.aspx.cs” Inherits=“_Default” %>

<title>Test Domino Post Page</title>    
<form id="form1" runat="server" method="post" action="http://myserver/test/testpost.nsf/(testagent)?openagent">

<div>

    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

<input type=submit value="submit me" />

</div>

</form>

The corresponding Domino agent has this:

Sub Initialize

Dim session As New NotesSession 

Dim db As notesdatabase



Dim doc As NotesDocument

Dim doc2 As notesdocument

Set doc = session.DocumentContext

Set db=session.CurrentDatabase



Set doc2=db.createdocument 

Call doc2.replaceitemvalue("Form", "main")

Call doc2.replaceitemvalue("testfield", doc.Request_Content(0))

Call doc2.save(True,True)

End Sub

This agent has a trigger of Agent List and Target of None.

The ACL has Anonymous with Editor access. The form in the database has one field called “testfield”.

Does anyone see a reason why documents are not being created? I’ve checkedthe log and it generates no errors.

Thanks!

Subject: HTTP Post to Domino agent from .NET form

The agent worked fine for me. Are you sure the agent is being triggered? Is Anonymous allowed to run agents on the server?

Subject: RE: HTTP Post to Domino agent from .NET form

I actually have the ACL wide open for Anonymous and I’m using the Run on Behalf Of field on the agent properties and it’s set to an admin ID that we use for all agents.

I really need to get this working so I can show the “majority” here that Domino plays well with others. I’m going to have an ASPX page with about 50 fields on it and I need to post the form to a Domino agent, have that agent parse the fields once posted and then process them into Domino databases. Is this even possible? I don’t want to use 50 query string variables and use a HTTP GET instead. Our standard is POST.

Thoughts? Anyone done this before?

Subject: RE: HTTP Post to Domino agent from .NET form

I created your aspx page jsut like you did, and everything worked as expected. Even with an added input field.

The only thing I did differently was the following:

Call doc2.ReplaceItemValue(“RC”, doc.Request_Content)

Try adding an input field or Try Request_Content without the (0).

Subject: RE: HTTP Post to Domino agent from .NET form

Stan, I never did get this to work. Is your ASPX page on the save server as your Domino agent? Mine are in totally different environments. I found this article that makes it appear as though posting from .NET to another system is not easy to pull off.

http://www.c-sharpcorner.com/UploadFile/desaijm/ASP.NetPostURL11282005005516AM/ASP.NetPostURL.aspx

If you have any other ideas I’d love to hear them. I’m almost ready to use a GET instead, but I hate to have to deal with the cumbersome querystring that will result. It’s going to be a monster in length.

Subject: RE: HTTP Post to Domino agent from .NET form

Other nuggets of information: when I go to that agent URL manually in IE, it creates a document in the database…just with no values, which is what I’d expect. However, it does create the document. Also, my aspx project is on my local machine, so it’s running from localhost. Would that have any bearing? I wouldn’t see why it would, but I figured I’d throw it out there. Thanks.

Subject: RE: HTTP Post to Domino agent from .NET form

That tells me that it’s not even being triggered from your aspx page. You can put a Msgbox(“Agent starting…”) statement at the beginning of your agent to see if its being triggered. The message will show on the domino console.

Subject: HTTP Post to Domino agent from .NET form

Call doc2.save(True,True)

Is this line creating the document as a response document with no parent?

Try

Call doc2.save(True,false)

just a thought, can’t see what else is wrong if there is no error output to the server console.

HTH

Andrew.