0
\$\begingroup\$

I'm using WWW class to sent a WWWForm to an asp.net server.
it used to work in unity 5.3.x but since I migrated to 5.6.3f1, it is not working and sending Send failed since rewinding of the data stream failed message.
I tried doing it with the UnityWebRequest but it couldn't send the data in the form and I would get null values in the server side. here is my code:


        WWWForm WF = new WWWForm();
        WF.AddField("UserID", ServerProperties.user.UserID);
        WF.AddField("UserEmail", ServerProperties.user.Email);
        WF.AddField("UserPassword", ServerProperties.user.Password);
        //I'm sending some json as strings. I don't need to do anything to the json data on the server
        WF.AddField("PlnFile", Export);
        WWW www =new WWW(ServerProperties.ServerAddress + "/Unity/SaveDesign", WF);
        while (!www.isDone)
        {
            yield return www.progress;
        }
        if (www.error != null)
            debug.Log(www.error);
        else
            debug.Log(www.text);

And I'm getting this request with [HttpPost] on the server.


        [HttpPost]
        public ActionResult SaveDesign(DesignViewModel _Design)

I'm reaching a deadline and I really need this, any ideas is appreciated.

\$\endgroup\$
1
\$\begingroup\$

For anyone getting this error in the future, your server might be configured to redirect some kinds of requests.
In my case I was requesting GET with an address like:"http://www.website.com/". AFAIK this should have worked for the POST requests as well, but it didn't, and after searching around I found this address to be working:"http://website.com/".
Maybe this is an obvious thing and I just didn't know about it. But anyway, this fixed it for me.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.