I read a lost of questions and answers about cross domain post here, but I still cannot make it work. The task seems so simple, but the data I get from the receiving side is always null.
In web application 1 (sender), I have this TestCrossDomainPost.html:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<form action="http://localhost:55400/TestCrossDomainReceive.aspx" method="post">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname"><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
In web application 2 (receiver), I have this TestCrossDomainReceive.aspx (nothing there):
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestCrossDomainReceive.aspx.cs" Inherits="WebApplication14.TestCrossDomainReceive" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
and TestCrossDomainReceive.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication14
{
public partial class TestCrossDomainReceive : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string fname = Request.Form["fname"];
string lname = Request.Form["lname"];
}
}
}
When I set debug point in Page_Load
, fname
and lname
are forever null
What do I miss here? I have debugged this for two days...