Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Apr 24, 2012 08:03 PM|LINK
First a bit more info which i should have included in the first place. First note that this example is just a simplified version of what i'm actually trying to do.
- So first, I'm posting the form data from a codebehind file using c# (not from an html page or via json).
- My uri is /api/newUser
- My route for the action looks pretty much the same: "api/newUser"
- My controller action looks like this: public
So in regards to digitalpacman's response of just adding a param to the action, that is fine, but in order to do that, won't that force me to change my uri and route? (I'm trying to keep the uri as /api/newUser). So instead of posting to a uri of /api/newUser,
wouldn't this force my uri to be "api/newUser/firstName".
Also, i tried to post via the codebehind using the application/x-www-form-urlencoded type, but without success. So i'm doing something like:
HttpWebRequest req = null;
HttpWebResponse res = null;
const string url = "http://localhost:8090/api/newUser";
req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = 900;
var sw = new StreamWriter(req.GetRequestStream());
res = (HttpWebResponse)req.GetResponse();
Stream responseStream = res.GetResponseStream();
var streamReader = new StreamReader(responseStream);
//Read the response into an xml document
var soapResonseXmlDocument = new XmlDocument();
apiResponse.Text = soapResonseXmlDocument.InnerXml;
Any clues as to what i'm doing wrong?