Basically I am trying to post data and redirect from one mvc application to another mvc application. I am NOT sending data through headers. Below is my code
public ActionResult Translation()
{
string Url = "http://localhost/MVCWebApplication2/Home/Index";
string sData = "some data"
string res = PostData(Url, sData);
return Redirect(Url);
}
public static string PostData(string sURL, string sData)
{
string result = "";
string _method = "POST";
try
{
// prepare request
HttpWebRequest wreq = (HttpWebRequest)WebRequest.Create(sURL);
wreq.Method = _method;
wreq.ContentType = "application/x-www-form-urlencoded";
wreq.ContentLength = sData.Length;
wreq.AllowAutoRedirect = true;
wreq.MaximumAutomaticRedirections = 10;
// post to server
Stream sw = wreq.GetRequestStream();
StreamWriter wr = new StreamWriter(sw);
wr.Write(sData);
wr.Close();
// get response
HttpWebResponse httpResponse = (HttpWebResponse)wreq.GetResponse();
Stream sr = httpResponse.GetResponseStream();
StreamReader rd = new StreamReader(sr);
result = rd.ReadToEnd();
httpResponse.Close();
}
catch (System.Exception ex) { return ex.Message.ToString(); }
return result;
}
Once the data is posted I am storing the data into Session, till this point it is working fine But after that I am redirecting it to that application then I am getting the Session Value as NULL, which is obvious ?
So, how can I post the data and redirect to the another application
Thanks for the help !