开发者

Send post data to asp.net page from classic asp

开发者 https://www.devze.com 2023-02-15 07:51 出处:网络
The goal is to popup an asp.net page from classic asp using post data, however, the asp.net page always has Request.Form variables as empty and shows RequestType get.

The goal is to popup an asp.net page from classic asp using post data, however, the asp.net page always has Request.Form variables as empty and shows RequestType get.

  1. I have stripped all the code from asp out, tested receiving the form variables sent from an html page on the asp.net page and this works fine. Copying the same form html to the asp page still gives no request.form data and a RequestType get

    <html>
    <head></head>
    <body>
        <form method="post" name="form" action="http://localhost:51307">
            <input nam开发者_开发问答e="uid" value="1" />
            <input type="submit" name="Submit" />
        </form>
    </body>
    

The asp site is using frames and the form is sent from a child frame, I'm unsure if this is the issue.

2. Assuming this worked, I had thought to submit a form in asp and use the onsubmit event of the form to popup the page which would send the form variables as post data. Is this the best way of doing this?

UPDATE The frames seem to be at fault here somehow, I have posted from the form within the framed page to another classic asp page and then redirected from this to the asp.net page.


This probably happened because "Navigate windows and frames across different domains" is disabled by default in IE browsers, which means you can't pass form data due to security reasons.


ASP.NET requires certain form fields to be set (usually as hidden fields, though HTTP POST obviously does not know the difference) for an inbound request to be treated as valid, thereby populating the relevant variables.

If I recall, you need to set __EVENTTARGET, __EVENTARGUMENT, and __VIEWSTATE.

Then, your ASP.NET code needs to be able to handle what was sent, as the default handlers will expect there to be something in __VIEWSTATE at a minimum. So, you would need to override the ViewState handler in your page. I can update with more information later when I'm at work, since I know I've done this before.


The problem is with the redirect. When you redirect a page, it creates a GET request instead of a POST request, and therefore will not have any form data.

Your options are to :

  1. Append the form values to the query string.
  2. Dynamically generate the form corresponding to the posted Request.Form collection, and submit it to the ASP.NET page using Javascript during the body onload event.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号