示例#1
0
        public IActionResult PUserCheckMail(UserRegisterRequest userRegisterRequest)
        {
            var baseDataR = new BaseDataRequest {
                Email = userRegisterRequest.Email
            };

            WebRequest request = WebRequest.Create("http://localhost:55106/api/user/IsEmailTaken");

            // If required by the server, set the credentials.
            request.Credentials = CredentialCache.DefaultCredentials;


            // Set the Method property of the request to POST.
            request.Method = "POST";

            // Create POST data and convert it to a byte array.
            byte[] byteArray = Encoding.UTF8.GetBytes(baseDataR.ToString());

            // Set the ContentType property of the WebRequest.
            request.ContentType = "application/x-www-form-urlencoded";
            // Set the ContentLength property of the WebRequest.
            request.ContentLength = byteArray.Length;


            // Get the response.
            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            // Display the status.
            Console.WriteLine(response.StatusDescription);
            // Get the stream containing content returned by the server.
            Stream dataStream = response.GetResponseStream();
            // Open the stream using a StreamReader for easy access.
            StreamReader reader = new StreamReader(dataStream);
            // Read the content.
            string responseFromServer = reader.ReadToEnd();

            return(View("Index"));
        }