Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi , please answer my question .
i have send parameters into mvc 4 project of windows application with webrequest .
i do work with under code
code in windows application :

C#
public string GetInformation(string strGUID)
        {
              
                string str = string.Format("{0}@{1}", strGUID, "GetInfor");
                string str2 = HttpPost("http://www.mysite.com/Customers/GetCustomerInformations", str);
                if (str2 != "")
                {
                    string[] strResult = str2.Split('@');
                }
               
                return str2;
            }

        public static string HttpPost(string URI, string Parameters)
        {
            string strResult = "";
            try
            {
                System.Net.WebRequest req = System.Net.WebRequest.Create(URI);
                req.ContentType = "application/x-www-form-urlencoded";
                req.Method = "POST";
                byte[] bytes = System.Text.Encoding.UTF8.GetBytes(Parameters);
                req.ContentLength = bytes.Length;
                System.IO.Stream os = req.GetRequestStream();
                os.Write(bytes, 0, bytes.Length);
                os.Close();
                System.Net.WebResponse resp = req.GetResponse();
                if (resp == null) return null;
                StreamReader sr = new StreamReader(resp.GetResponseStream());
                strResult = sr.ReadToEnd().Trim();
            }
            catch (Exception e)
            {
                strResult = "";
               
            }
            return strResult;
        }

the code in mvc 4:

C#
[HttpPost]
       public ActionResult GetCustomerInformations()
       {
           string SendInformation = string.Format("{0}@{1}", "D", "3000");
           try
           {
               Request.InputStream.Position = 0;
               if ( HttpContext.Request.InputStream != null)
               {
                   StreamReader reader = new StreamReader(HttpContext.Request.InputStream);
                   String xmlData = reader.ReadToEnd();
                   string[] strrequest = xmlData.Split('@');
                   var findCustomer = Customer.GetByGUID(strrequest[0]);
                   if (findCustomer != null)
                   {

                       SendInformation = string.Format("{0}@{1}@{2}@{3}@{4}@{5}@{6}@{7}@{8}@{9}@{10}", findCustomer.Company, findCustomer.Tel, findCustomer.Tel2,
                        findCustomer.Fax, findCustomer.Email, findCustomer.Name, findCustomer.Version, findCustomer.InstallOnDate, findCustomer.InstallOnDateM,
                        findCustomer.InstallPath, findCustomer.Address);
                   }
                   else
                   {
                       SendInformation = string.Format("{0}@{1}", "D", "3001-notfindCustomers" + "-Code:" + strrequest[0] );
                   }

               }
               else
               {
                   SendInformation = string.Format("{0}@{1}", "D", "3010-nullString");//new
               }
           }
           catch
           {
               SendInformation = string.Format("{0}@{1}", "D", "2001-cash");
           };
           return Content(SendInformation);
       }


this code is worked with .net framework 4 , but when update host to .net framework 4.5 this code not worked , when call action in mvc 4 get error 404 page not found and when remove [httpPost] not send parameters in windows application , and Request.InputStream is empty

please help me . please say me how to resolved this .
Posted
Updated 27-Sep-13 21:29pm
v2
Comments
Mehdy Moini 27-Sep-13 23:51pm    
Please format your code as code in all your questions!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900