How to call a URL(script) after posthttp://forums.asp.net/t/1772080.aspx/1?How+to+call+a+URL+script+after+postWed, 22 Feb 2012 13:38:56 -050017720804843098http://forums.asp.net/p/1772080/4843098.aspx/1?How+to+call+a+URL+script+after+postHow to call a URL(script) after post <p>Hi there, got following problem: I want to upload a large amount of image data to the server. Once this is done, I need to start a script on the server to process the data (in this case, it's python). I could start the script with a parameterized call. So my question is, how would I build the url and send it automatically after the upload is complete. I'm using if(IsPost) and a counter to upload the images. I think I can not use the action parameter in the form tag. Am i right?</p> <p>Thanks for the help.</p> 2012-02-21T12:16:13-05:004843598http://forums.asp.net/p/1772080/4843598.aspx/1?Re+How+to+call+a+URL+script+after+postRe: How to call a URL(script) after post <p>Can't you just use a redirect from the code behind?</p> <p>Response.Redirect(&quot;script.py&quot;);</p> 2012-02-21T17:21:17-05:004843718http://forums.asp.net/p/1772080/4843718.aspx/1?Re+How+to+call+a+URL+script+after+postRe: How to call a URL(script) after post <p>I have to send a few parameters from user-input to the script. I think that's not possible with the redirect.</p> 2012-02-21T18:52:54-05:004844032http://forums.asp.net/p/1772080/4844032.aspx/1?Re+How+to+call+a+URL+script+after+postRe: How to call a URL(script) after post <p>If script accepts parameters from a query string, use &quot;script.py?x=1&amp;y=2&quot;. In other case, use HTTP POST</p> <pre class="prettyprint">string url = &quot;http://...&quot;; HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url); string proxy = null; string data = String.Format(&quot;parameter1={0}&amp;parameter2={1}&amp;parameter3={2}&quot;, parameter1, parameter2, parameter3); byte[] buffer = Encoding.UTF8.GetBytes(data); req.Method = &quot;POST&quot;; req.ContentType = &quot;application/x-www-form-urlencoded&quot;; req.ContentLength = buffer.Length; req.Proxy = new WebProxy(proxy, true); // ignore for local addresses req.CookieContainer = new CookieContainer(); // enable cookies Stream reqst = req.GetRequestStream(); // add form data to request stream reqst.Write(buffer, 0, buffer.Length); reqst.Flush(); reqst.Close(); HttpWebResponse res = (HttpWebResponse)req.GetResponse(); Stream resst = res.GetResponseStream(); StreamReader sr = new StreamReader(resst); string response = sr.ReadToEnd();</pre> <p>Hope this helps.</p> 2012-02-22T01:59:28-05:004844661http://forums.asp.net/p/1772080/4844661.aspx/1?Re+How+to+call+a+URL+script+after+postRe: How to call a URL(script) after post <p>Thank you for your help. I'm new in programming, so sorry for my questions. I got an error in the following three lines: (the name encoding is not &nbsp;available in the actual context...)</p> <p>byte[] buffer = Encoding.UTF8.GetBytes(data);</p> <p>req.ContentLength = buffer.Length;</p> <p>reqst.Write(buffer, 0, buffer.Length);</p> <p></p> <p>Is there a possibility to set up a simple site to test, how the post gets submitted?</p> 2012-02-22T08:16:49-05:004844671http://forums.asp.net/p/1772080/4844671.aspx/1?Re+How+to+call+a+URL+script+after+postRe: How to call a URL(script) after post <p>Please visit this link</p> <p>http://msdn.microsoft.com/en-us/magazine/cc163941.aspx</p> 2012-02-22T08:20:52-05:004845335http://forums.asp.net/p/1772080/4845335.aspx/1?Re+How+to+call+a+URL+script+after+postRe: How to call a URL(script) after post <p>You need to add&nbsp;system.text namespace in your class.</p> <p>using&nbsp;System.Text;</p> <p>Regarding test script.&nbsp;Suppose you're posting a variable called &quot;username&quot;</p> <p>If using .cgi</p> <pre class="prettyprint">import cgi form = cgi.FieldStorage() print form[&quot;username&quot;]</pre> <p>if using .py:</p> <pre class="prettyprint">form = web.input() print form.username</pre> 2012-02-22T13:38:56-05:00