如何从发布到asp.net传统的ASP页面 [英] How to post a page from asp.net to classic ASP

查看:163
本文介绍了如何从发布到asp.net传统的ASP页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想某种形式张贴变量成经典ASP页。我不希望有改变,因为工作,将需要完成的数量,并消耗他们的网页量的传统的ASP页面。

I'd like to post some form variables into a classic ASP page. I don't want to have to alter the classic ASP pages, because of the amount of work that would need to be done, and the amount of pages that consume them.

经典的ASP页面预计表单变量的用户名和的userPassword提交给他们。

The classic ASP page expects form variables Username and Userpassword to be submitted to them.

username = Request.Form("UserName")
userpassword = Request.Form("Userpassword")

然后,它执行各种操作和设置课程,进入一个ASP应用程序。

It then performs various actions and sets up sessions, going into an ASP application.

我想这些变量提交到从ASP.NET的页面,但登录控件嵌套在用户控件和模板,所以我不能让表单元素的名称是用户名和的userPassword。

I want to submit these variables into the page from ASP.NET, but the login control is nested inside usercontrols and templates, so I can't get the form element's names to be "username" and "UserPassword".

任何想法?

推荐答案

您不能真正前进上,后像你想这样做(在您的OP)。客户端具有启动POST到ASP页(S)(在你的第二个职位的code正在做)。

You can't really "forward" a POST on, like you're wanting to do (in your OP). The client has to initiate the POST to your ASP page(s) (which the code in your second post is doing).


下面是从你自己的答复自发布code,所以你可以标记一个答案,像你这样的建议:

Here's the self-POSTing code from your own reply so you can mark an answer, like you suggested:

public class  RemotePost{
     private  System.Collections.Specialized.NameValueCollection Inputs 
     = new  System.Collections.Specialized.NameValueCollection() ;

    public string  Url  =  "" ;
    public string  Method  =  "post" ;
    public string  FormName  =  "form1" ;

    public void  Add( string  name, string value ){
        Inputs.Add(name, value ) ;
     }

     public void  Post(){
        System.Web.HttpContext.Current.Response.Clear() ;

         System.Web.HttpContext.Current.Response.Write( "<html><head>" ) ;

         System.Web.HttpContext.Current.Response.Write( string .Format( "</head><body onload=\"document.{0}.submit()\">" ,FormName)) ;

         System.Web.HttpContext.Current.Response.Write( string .Format( "<form name=\"{0}\" method=\"{1}\" action=\"{2}\" >" ,

        FormName,Method,Url)) ;
            for ( int  i = 0 ; i< Inputs.Keys.Count ; i++){
            System.Web.HttpContext.Current.Response.Write( string .Format( "<input name=\"{0}\" type=\"hidden\" value=\"{1}\">" ,Inputs.Keys[i],Inputs[Inputs.Keys[i]])) ;
         }
        System.Web.HttpContext.Current.Response.Write( "</form>" ) ;
         System.Web.HttpContext.Current.Response.Write( "</body></html>" ) ;
         System.Web.HttpContext.Current.Response.End() ;
     }
}

这篇关于如何从发布到asp.net传统的ASP页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆