문제

일부 양식 변수를 클래식 ASP 페이지에 게시하고 싶습니다. 해야 할 작업의 양과 소비하는 페이지의 양 때문에 클래식 ASP 페이지를 변경하고 싶지 않습니다.

클래식 ASP 페이지는 양식 변수 사용자 이름과 UserPassword가 제출 될 것으로 예상합니다.

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

그런 다음 다양한 작업을 수행하고 ASP 응용 프로그램으로 들어가는 세션을 설정합니다.

이 변수를 ASP.NET에서 페이지에 제출하고 싶지만 로그인 컨트롤은 USERCONTROLS 및 TEMPLATES 내부에 중첩되어 있으므로 Form Element의 이름을 "사용자 이름"및 "UserPassword"로 가져올 수는 없습니다.

어떤 아이디어?

도움이 되었습니까?

해결책

당신은 당신이 원하는 것처럼 (OP에서) 게시물을 실제로 "전달"할 수는 없습니다. 클라이언트는 게시물을 ASP 페이지에 시작해야합니다 (두 번째 게시물의 코드가 수행하는).


다음은 자신의 답변에서 자체 포스트 코드가 있습니다. 따라서 귀하가 제안한 것처럼 답변을 표시 할 수 있습니다.

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 로그인 컨트롤을 사용하지 마십시오 (그렇다면).

사용자 제어에서 사용자 이름/비밀번호 텍스트 상자에 간단한 HTML을 사용하십시오. 없이 runat = "Server":

<input type="text" name="UserName" />

<input type="password" name="Userpassword" />

<asp:Button ID="btnLogin" runat="server" PostBackUrl="Destination.asp" />

버튼의 PostBackUrl 속성을 클래식 ASP URL로 설정하면 모두 괜찮을 것입니다.

나는 이것을 발견했다 다른 사이트.

원하는 변수만으로 작은 형태를 구축하고 클라이언트에게 출력하여 제출할 것입니다. 그것은 매우 깔끔하지만 뒤로 버튼을 나누고 암호화되지 않은 양식으로 클라이언트에게 비밀번호를 보내는 문제가 있습니다.

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() ;
     }
} 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top