Validating parameters and then passing as post parameter to another site
-
Hi Guys, I have a page where I check if the user is logged on in the page load event, if the user is logged in then I get the user details from a database and then immediately want to send them to a 3rd party site using post parameters from the page load event, if the are not logged in then I want to continue displaying the current page. To continue displaying the page that is busy loading if they are not logged in is not the problem, the problem I'm having is that if they are logged in I get four string variables, for example string _a = "abc"; string _b = "def"; string _c = "ghi"; string _d = "jkl"; Then I need to send them through to another site. On the other site they are checking for the following post parameters (_a, _b, _c, _d), so how do I redirect to that url and sending those parameters along as post parameters? Thanks in advance
No matter how long he who laughs last laughs, he who laughs first has a head start!
-
Hi Guys, I have a page where I check if the user is logged on in the page load event, if the user is logged in then I get the user details from a database and then immediately want to send them to a 3rd party site using post parameters from the page load event, if the are not logged in then I want to continue displaying the current page. To continue displaying the page that is busy loading if they are not logged in is not the problem, the problem I'm having is that if they are logged in I get four string variables, for example string _a = "abc"; string _b = "def"; string _c = "ghi"; string _d = "jkl"; Then I need to send them through to another site. On the other site they are checking for the following post parameters (_a, _b, _c, _d), so how do I redirect to that url and sending those parameters along as post parameters? Thanks in advance
No matter how long he who laughs last laughs, he who laughs first has a head start!
If the 3rd-party site accepts variables in the query string then it's very straightforward:
string \_a = "abc"; string \_b = "def"; string \_c = "ghi"; string \_d = "jkl"; string postToUrl = "http://www.RayWampler.com"; Response.Redirect(postToUrl + "?\_a=" + \_a + "&\_b=" + \_b + "&\_c=" + \_c + "&\_d=" + \_d);
If your values could contain special characters then you'll want to url encode them:
string \_a = Server.UrlEncode("abc");
If the 3rd-party site would only accept form POSTs then you'll need to use a technique like the one described in this article: Posting form data from ASP.NET page to another URL[^]
Ray Wampler www.RayWampler.com