Dashsa
Dashsa

Reputation: 718

.Net C# post form to external URL

I am new to .NET - I have been a classic ASP developer for a while. I am trying to post an HTML form to saleforce and I am having some issues. I am using .NET webforms 4.0 with a master page.

If I was doing this in classic ASP, I would simply change the form action to the Salesforce URL. But with webforms, I guess the form is submitting back to the page.

I think I am supposed to postback and collect the data form the form and then send it to salesforce, but I am not sure how to do that... Thanks for any help!

Upvotes: 0

Views: 1335

Answers (2)

Jimmy Mattsson
Jimmy Mattsson

Reputation: 2113

You can use Webclient and UploadValues in the postback event to post to external Url. This will keep you on your website aswell, but if you want to end up to on the external website, this solution wont work.

System.Net.WebClient myWebClient = new System.Net.WebClient();
myWebClient.UploadValues(ExternUrl, PostData);

Upvotes: 1

Eli Gassert
Eli Gassert

Reputation: 9763

The answer is simply: don't use a webform (runat="server") and instead just create a regular old form. Then set the action attribute to post to salesforce and you're done.

This would be how you'd do it compared to the classic ASP method, which doesn't have webforms (viewstate, viewbag, etc).

Upvotes: 1

Related Questions