2014-01-24 66 views
0

我有一個應用程序需要在默認Web瀏覽器上打開外部URL,但我不想在URL上顯示參數,所以我認爲我需要一個POST而不是一個GET,但是如何?在默認Web瀏覽器上打開網頁並隱藏URL參數

我用下面的代碼打開外部的默認瀏覽器

Friend Sub WebOpen(ByVal WebAddress As String) 
    Dim sInfo As New ProcessStartInfo(WebAddress) 
    Process.Start(sInfo) 
End Sub 

但這暴露的URL欄上所有的參數,因爲做一個GET不是POST。


解決方案: 創建一個臨時的HTML文件,並使用以前的代碼打開它(WebOpen(BYVAL WebAddress作爲字符串))

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 
<!-- <!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" xmlns:v="urn:schemas-microsoft-com:vml"> 
<!--  <head> 

    </head> --> 
<body> 
    <form name="Login" method="post" action="http://www.yourWebPage.com/" target="_self"> 
    <input id="accountLoginField" class="textInput" name="account" value="accountX" size="24" 
     maxlength="32" type="hidden"/> 
    <input id="userLoginField" class="textInput" name="user" value="userX" size="24" 
     maxlength="32" type="hidden"/> 
    <input class="textInput" name="password" value="PassX" size="24" maxlength="32" type="hidden"/> 
    <input name="submit" value="Start Session" type="submit" id="btn" style="color: transparent; 
     background-color: transparent; border-color: transparent; cursor: default;"/> 
    <script type="text/javascript"> 
       <!-- 
     var counter = 0; 
     var maxCount = 50; 

     function pushSubmit() { 
      if (counter++ < maxCount) { 
       document.getElementById('btn').click(); 
      } 
     } 
     //start the process 
     window.setTimeout(pushSubmit(), 30);    
    </script> 
    </form> 
</body> 
</html> 
+1

你正在尋找的答案是這樣的頁面: [StackOverflow上(http://stackoverflow.com/questions/1705201/how-to-open-ie-with-post-info-in-c ) –

+0

好的,感謝您的信息,現在我有一個HTML文件的按鈕,它工作正常。有什麼辦法可以讓HTML文件打開時自動點擊該按鈕? –

+0

HTML文件或Windows窗體中的按鈕? –

回答

0

你可以在vb.net中使用字符串加密(你必須找到你自己),然後執行以下操作:

的Process.Start(解密( 「encryptedstringhere」))

這會'隱藏'試圖反編譯代碼的任何人的參數。 或 一旦你編譯了你的可執行文件,找到一個vb.net混淆程序(只是谷歌它)和混淆你的exe文件。這會讓nayone試圖反編譯它或找到你的參數中的字符串是不可讀的......

希望這有幫助!

Rodit

+0

我不想混淆我的代碼,我只想在默認Web瀏覽器中打開一個網頁,隱藏參數以從用戶登錄到Web頁面;這就是爲什麼我需要做一個POST而不是GET。但是,謝謝我會考慮到這一點,以防萬一我需要。 –

相關問題