I'm trying to achieve the following:
I'm building an MVC website that will help me to automatically redirect to another site. WebsiteA will call WebsiteB using HttpWebRequest. WebsiteA will send the details of the user through headers (request.headers.add) WebsiteB will handle all the user details and it should not give response to WebsiteA and page should be redirect to requseted page.
WebApplication 1 :
public ActionResult RedirectPage(string firstName,string lastName)
{
var url = "http://localhost:64603/";
var request = (HttpWebRequest)WebRequest.Create(url);
request.Headers.Add("firstName", firstName);
request.AllowAutoRedirect = false;
var response = (HttpWebResponse)request.GetResponse();
return new RedirectResult(url);
}
Web Application 2 :
public ActionResult Index()
{
var re = Request;
var headers = re.Headers;
if (Request.Headers["firstName"] != null)
{
string ss = Request.Headers["firstName"].ToString();
}
ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
return View();
}
So, my requirement is the page should be redirected from WebApplication1 to WebApplication2 and data should be send through headers.