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 :
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:
[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");
}
}
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 .