我有一个本地的登录网页,想实现的功能是在winform上点一个button,IE打开这个本地网页,然后自动登录,
用户名密码最好是程序传进去
这个该怎么办到?试过用webbrowser,但是后续的网页上点了一个按钮后会跳到IE上打开新网页,然后session和cookie不能传递过去,导致要重新输用户名和密码登录,看了网上的教程,想做到强制在同一个webbrowser打开,但没有实现。
所以现在希望能直接在用IE打开,然后自动登录。
谢谢!

解决方案 »

  1.   

    参考:
    http://www.google.com.hk/#hl=zh-CN&newwindow=1&safe=strict&q=+site:topic.csdn.net+webbrowser+ie+%E5%85%B1%E4%BA%AB+cookie&sa=X&ei=QxbqTvrQKabcmAW-5t2gCg&ved=0CDAQrQIwAA&bav=on.2,or.r_gc.r_pw.,cf.osb&fp=bc5fd6da1ee87cbb&biw=1280&bih=929
      

  2.   

    找的我眼睛都花了,呵呵其实我想要的很简单,也有可能是我想的简单了,我的登录页面是这样的<html>
    <body>
    <form action="https://ti-pass.ext.ti.com/cgi-bin/login/login.pl"
                method="post" name="userid_form" enctype="application/x-www-form-urlencoded">
        <input type="text" name="fld2" id="fld2" /><br/>
        <input type="text" name="fld5" id="fld5" autocomplete="off" /><br/>
        <input type="image" tabindex="103" src="./myti_gl_submit.gif" alt="Submit" name="Submit" />
        <input type="hidden" name="fld1" value="a8f4565d0a1295e506191718d2d3f65d" />
        <input type="hidden" name="portal" value="1" />
        <input type="hidden" name="OKPage" value="http://ftds.ext.ti.com/WLTV/AppServlet?action=CheckPermissionServ&forward=jsp/MainPage.jsp" />
        <input type="hidden" name="fld4" value="all" />
        <input type="hidden" name="provider" value="TIPassLoginSingleContainer" />
        <input type="hidden" name="ErrPage" value="https://myportal.ti.com:443/portal/dt?OKPage=http%3A%2F%2Fftds.ext.ti.com%2FWLTV%2FAppServlet%3Faction%3Dnull%26jspURL%3Djsp%2FAbout.jsp&provider=TIPassLoginSingleContainer" />
    </form>
    </body>
    </html>
    点button后能够在IE打开这个网页,将id和password传给fld2和fld5这两个text,然后submit实现登录
      

  3.   

    如果是webbrowser控件就很容易,要是外部的IE,就得用API把内容发送到IE的窗口中,估计只能模拟输入,而不能靠html来定位传值了
      

  4.   

    在webbrowser上实现自动登陆后到了一个页面,该页面的代码如下<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="/WLTV/css/ffwMenu/itsglobal/css/itsglobal.css" />
    <link rel="stylesheet" href="/WLTV/css/ffwMenu/styles/ffw.css" />
    <link rel="stylesheet" href="javascript/tabsSearch.css" type="text/css">
    <script type="text/javascript" src="javascript/tabMenu.js"></script>
    <title>MainPage Page</title>
    </head>
     
    <body class="dialogBody">
     
    <table class="dialogTable" width="700">
    <tr>
    <td class="dialogTitleCell">&nbsp;Wafer Layout and TWIFF Viewer (WLTV)</td>
    </tr>
    <tr>
    <td class="dialogCellB" style="padding: 1em;">The Wafer Layout
    and TWIFF Viewer provides:
    <ul style='margin-bottom: 0px; margin-top: 0px'>
    <li>Validation of format and content of WaferConfiguration XML and
    PCM_TWIFF ASCII runtime files.</li>
    <li>Visualization of a wafer based on the WaferConfiguration
    information and potentially including an overlay of PCM_TWIFF runtime
    information.</li>
    </ul>
    <br />
    From this page either a WaferConfiguration or PCM_TWIFF runtime file
    (or both) can be uploaded for validation and visualization. If both
    file types are available more extensive validation and visualization
    options are available.</td>
    </tr>
     
    <tr>
    <td>
    <table border='1' cellpadding='0' cellspacing='0' width='100%'>
    <tr>
    <td>
     
     
     
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
        
        
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
        <head>        
            <title>XML UPLOAD</title>
            <script type="text/javascript" src="javascript/upload.js"></script>
            <link rel="stylesheet" href="/WLTV/css/ffwMenu/itsglobal/css/itsglobal.css" />
    <link rel="stylesheet" href="/WLTV/css/ffwMenu/styles/ffw.css" />
            <script type="text/javascript" src="javascript/wltv.js"></script>
            <script type="text/javascript" src="javascript/tabMenu.js"></script>
                    
            
        </head>
        <body class="dialogBody">
            <form id="uploadForm" name="uploadForm" action="Upload.jsp" enctype="multipart/form-data" method="post">                  
                <table border='0' cellpadding='0' cellspacing='0' width='95%'>
                    <tr><td>&nbsp;</td></tr>
                    <tr>
                        <td width="40%" align="right" nowrap="true" style="padding-bottom: 4px;">&nbsp;WaferConfiguration file:&nbsp;</td>
                        <td width="60%" align="center" style="padding-bottom: 4px;"><input name="myInput" id="file1" type="file" size="65" onKeyDown='clearKeycode (this,event)' /></td>
                    </tr>
                    <tr>
                        <td width="40%" align="right" nowrap="true">&nbsp;PCM_TWIFF file:&nbsp;</td>
                        <td width="60%" align="center"><input name="myInput" id="file2" type="file" size="65" onKeyDown='clearKeycode (this,event)'  /></td>
                    </tr>              
     
                    <tr>
                        
                        <td colspan="2" align="center" style="padding-top: 1em; padding-bottom: 1em;">
                            <input class="primary_button" style="margin-right: 1em;" TYPE="Button" name='Upload' Value=' Process ' onClick='javascript:processElements("AppServlet?action=PerformContentValidation&jspURL=jsp/DisplayContent.jsp&exist=false")'>            
                            <input type="reset" name="Reset" value="   Reset   " class="secondary_button"  >
                        </td>
                        
                    </tr> 
                </table>
            </form>
        </body>
    </html>
    </td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
     
    </body>
    </html>
    在那个name是upload的button上点击后响应了onclick事件,然后上传file1和file2这2个input里的文件,自动跳出一个IE窗口显示结果。
    有办法把这个新跳出的IE窗口放在原先的webbrowser上显示吗?或者显示在新的webbrowser上