我的page_load请求中的aspx c#始终是GET,如何将其发布?

时间:2019-03-28 01:22:56

标签: c# asp.net post pageload

我需要从RestTemplate Spring调用,并且在我的aspx的page_load中始终是GET并从客户端发送POST方法。

public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.HttpMethod == "POST")//This code is always GET and never is POST, i'm using RestTemplate library from android Spring postForObject method
            {
                MemoryStream memstream = new MemoryStream();
                Request.InputStream.CopyTo(memstream);
                memstream.Position = 0;
                using (StreamReader reader = new StreamReader(memstream))
                {
                    string text = reader.ReadToEnd();
                }
            }
        }
    }

如何接受POST?在GET情况下,我的InputStream为空。

更新

我从Java android使用RestTemplate postForObject调用

RestTemplate restTemplate = new RestTemplate();         
            String lsObjeto = restTemplate.postForObject("http://xxxx/Service/Login", "{user:666,pwd:123}", String.class);  
            Log.v("URL", "Response: " + lsObjeto);

0 个答案:

没有答案