Question

I need to pass some data from a classic ASP application to my ASP.NET app using the POST method (can't use GET sorry) in a form.

This doesn't seem to work if my action is the target aspx page but my ASP.NET app is using forms authentication, because it looks like somewhere in the pipeline my data is lost, given that the Request.Form collection is null in the Page_Load method of my login page.

If I disable forms authentication, the target page receives the posted data without a problem.

Do you know how can I work-around this problem? When or where could I obtain this data?

Thanks in advance!

Was it helpful?

Solution

A possibility might be to transfer the posted headers into a session object you maintain in your ASPX side that would then be killed once its purpose is complete.

void Session_Start(object sender, EventArgs e) 
{
    // Code that runs when a new session is started
    SortedList sList = new SortedList();
    foreach (string key in HttpContext.Current.Request.Form.Keys)
    {
        sList.Add(key, HttpContext.Current.Request.Form[key]);
    }
    Session.Add("myList", sList);

}

OTHER TIPS

Can you just unprotect the single page that's the target of the POST?

In your web.config:

<configuration>
  <location path="MyPostHandlingPage.aspx">
    <system.web>
      <authorization>
        <allow users="*" />
      </authorization>
    </system.web>
  </location>
</configuration>

The 2 possible way to transfer data between asp to aspx is

  1. using Session, Via SQL DB (Ref. http://msdn.microsoft.com/en-us/library/aa479313.aspx

  2. Using QueryString in a intermediate ASP page as below.

Your 1st ASP page : sample.asp

<% language="VBScript"%>
<html>
<head>
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" action="process.asp" method="post">
    <div>
        &nbsp;<input name="Text1" id="Text1" type="text" />
        <input id="Submit2" type="submit" value="submit" /></div>
    </form>
</body>
</html>

Your Intermediate page : process.asp

<%@ language="vbscript"%>
<html>
<head>
    <title>Untitled Page</title>
</head>
<body>
    <form id="form2">
    <%response.Write(Request.Form("Text1"))
     %>
    <%response.Redirect("default3.aspx?icontent=" & Request.Form("Text1"))  %>
    </form>
</body>
</html>

Your ASPX code page : Default.aspx

public partial class Default3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write(Request.QueryString["icontent"].ToString());
    }

}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top