顯示具有 ASP 標籤的文章。 顯示所有文章
顯示具有 ASP 標籤的文章。 顯示所有文章

2016年7月20日 星期三

How do I enable upload of large files in classic ASP on IIS 7?

Recently I had to get an old ASP application working in IIS 7.5 on a W2K8 server. Almost everything works fine, except that I can't seem to get it to accept uploads larger than ~200kB. I did find a setting, that from what I can understand should to the trick, in the applicationHost.config, I set the max request size to 100 MB like this:
<location path="TheNameOfMySite">
    <system.webServer>
        <security>
            <requestFiltering>
                <requestLimits maxAllowedContentLength="104857600" />
            </requestFiltering>
        </security>
    </system.webServer>
</location>
Unfortunately, this seems to do nothing at all, it still refuses to accept any files larger than about 200 kB, and in the log file it gives this error message:
ASP_0104_:_80004005|Operation_not_Allowed
Googling that points to increasing the maxAllowedContentLength as I have done above. So I'm fresh out of ideas, but confident that the clever stackoverflow crowd can solve this in less time than it took for me to write this question.

The maxAllowedContentLength controls how much data is allowed to be sent in a response. However you want to control how much can be accepted in a request. This is handled by themaxRequestEntityAllowed attribute of the limits element in the asp section of the config file. An example might look like:-
<system.webServer>
  <asp>
     <cache diskTemplateCacheDirectory="%SystemDrive%\inetpub\temp\ASP Compiled Templates" />
     <limits scriptTimeout="00:02:00"
        queueConnectionTestTime="00:00:05"
        requestQueueMax="1000"
        maxRequestEntityAllowed="104857600"
        />
  </asp>
You can configure this in the IIS7 manager under the "Limit Properties" category in the property grid for the ASP feature. Alternatively you can use a command line:-
appcmd set config /section:asp /limits.maxRequestEntityAllowed:104857600
Note that extending this value increase the window for DOS attack where the attacker sends large content to the server so don't be tempted to extend this beyond what you really need.

IIS7.0 ASP 啟用上層路徑

http://itgroup.blueshop.com.tw/inmarkblue/markshu?n=convew&i=6684

開啟IIS管理員
ASP/ 開啟功能
將啟用上層路徑 及 將錯誤傳送到瀏覽器 選取

部署傳統 ASP 伺服器

若要部署傳統 ASP 伺服器

使用 Web Platform Installer (Web PI) 可以讓您輕鬆安裝 IIS 以及在 IIS 上執行的應用程式。 因為 Web PI 會安裝最新版本的可用 Web Platform 提供項目,所以只需要幾個簡單的按選動作,您就可以下載並安裝任何新工具或更新。 如需深入了解 Web PI,請參閱深入了解並安裝 Web PI (英文)。
您也可以藉由使用 Windows 使用者介面 (UI) 或是從命令列來執行這個程序。

若要在 Windows Server 2008 或 Server 2008 R2 中使用 UI

  1. 按一下 [開始],指向 [系統管理工具],然後按一下 [伺服器管理員]。
  2. 在 [角色摘要] 中,按一下 [新增角色]。
  3. 使用 [新增角色精靈] 新增 [網頁伺服器 (IIS)] 角色。
    如需如何安裝預設 IIS 7 網頁伺服器的詳細資訊,請參閱部署靜態內容伺服器 (IIS 7)。
  4. 在 [選取角色服務] 頁面上,注意預設安裝之預先選擇的角色服務,然後選取下列其他角色服務:
    • ASP
    • 要求篩選
    • ISAPI 擴充程式
  5. 在 [要安裝的功能摘要] 頁面上,確認您所做的選擇,然後按一下 [安裝]。
  6. 在 [安裝結果] 頁面上,確認成功完成要安裝的網頁伺服器 (IIS) 角色以及所需的角色服務,然後按一下 [關閉]。
  7. 若要確認 IIS 安裝成功,請將下列網址輸入網頁瀏覽器:
    http://localhost
    您應該會看見預設的 IIS 7 歡迎使用畫面。

若要在 Windows Vista 或 Windows 7 中使用 UI

  1. 按一下 [開始],然後按一下 [控制台]。
  2. 在 [控制台] 中,按一下 [程式集],再按一下 [開啟或關閉 Windows 功能]。
  3. 在 [Windows 功能] 對話方塊中,按一下 [Internet Information Services] 以安裝預設功能,然後選取下列其他功能:
    • ASP
    • 要求篩選
    • ISAPI 擴充程式
  4. 按一下 [確定],關閉 [Windows 功能] 對話方塊。
  5. 若要確認 IIS 安裝成功,請將下列網址輸入網頁瀏覽器:
    http://localhost
    您應該會看見預設的 IIS 歡迎使用畫面。

若要使用命令列

  • 將下列命令輸入成一個指令碼:
    Start /w pkgmgr /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-ApplicationDevelopment;IIS-ASP;IIS-ISAPIExtensions;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-Security;IIS-RequestFiltering;IIS-HttpCompressionStatic;IIS-WebServerManagementTools;IIS-ManagementConsole; WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI

2011年9月27日 星期二

vbscript中怎麼調用javascript函數

vbscript中怎麼調用javascript函數
1。在一般情形下,你可以直接調用的,譬如  
   
  <script   language=javascript>  
  function   openwin(str)  
  {  
  window.open("/sgh/district/districtsearch.jsp?value="+str,"","width=400,height=600,scrollBars,resizable");  
  //showModalDialog("districtsearch.jsp?value="+str);  
  }  
   
  </script>  
  <SCRIPT   ID=clientEventHandlersVBS   LANGUAGE=vbscript>  
  <!--  
   
  Sub   BossSoftPhone1_BeforeSoundRecord  
      call   openwin("abc")  
  End   Sub  
   
  -->  
  </SCRIPT>  
   
  <input   type=button   value="click   me"   Onclick="Vbscript:   call   BossSoftPhone1_BeforeSoundRecord()">  
   
   
  參考  
   
  Using   VBScript   and   JScript   on   a   Web   Page  
 
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvid/html/msdn_vbnjscrpt.asp  
   
  2。去掉後面的「;」,譬如  
   
  window.open   "
http://sgh/district/districtsearch.jsp?value="+str,"","width=400,height=600,scrollBars,resizable"  
   
  或者  
       
  call   window.open("
http://sgh/district/districtsearch.jsp?value="+str,"","width=400,height=600,scrollBars,resizable")  
   
   
  3。應該是類似的,(把   '換成   ",因為在VBSCRIPT裡,'   是註釋符號)  
   
  call   parent.right.custmsg.searchwin   ("8888")  
   
  或者  
   
  parent.right.custmsg.searchwin   "8888"


腳本語言的選擇往往基於許多不同原因:它可能是開發者最為熟悉的語言,可能是對給定工程來說能夠提供最多特色支持的,也有可能是最具效率的。不同的環境和要求使得我們在選擇腳本語言時注重不同的因素,同時也使得我們在某些時候面臨選定的腳本語言不能直接提供其它語言固有的函數這一問題,或某個腳本已經寫成但用的卻是另外一種腳本語言。    
   
    此時應該怎麼辦?是否需要用當前所用的腳本語言重寫這些腳本?或者說,是否有可能在一種腳本語言中調用其它腳本語言的內置函數?本文要說明的就是在ASP應用中如何讓VBScript腳本和JScript腳本交互以最大限度地獲得兩種腳本語言的特色支持。    
   
    一、VBScript和JScript的內置函數    
   
    在VBScript和JScript中,有大量的內置函數功能是相同或類似的。然而,在一種腳本語言中內置的函數並非總是在另外一種腳本語言中也有對應的函數。例如,VBScript提供了許多用於操作字符串和格式化數據的函數,這些函數在JScript中並不存在。這些函數包括StrReverse()、Filter()以及FormatCurrency()等。在另一方面,JScript所提供的用於管理數組、字符串編碼等的函數在VBScript中也沒有定義,如join()、reverse()、pow()、位操作、escape()和unescape()等。    
   
    那麼,如果在JScript程序中需要一個VBscript函數該怎麼辦呢?    
   
    二、異種腳本的互相調用    
   
    如果需要在JScript腳本中調用一個VBScript中內置的函數,則應該寫一個VBScript用戶定義函數(在這裡調用VBScript內置函數),然後在JScript腳本中象調用公用JScript函數一樣調用這個用戶定義函數。    
   
    例如,如果要調用的VBSCript內置函數是FormatCurrency(),則可以聲明如下自定義函數:    
   
    <SCRIPT   LANGUAGE="VBSCRIPT"   RUNAT="SERVER">    
    Function   Formatvalue(value)    
      Formatvalue   =   FormatCurrency(value)    
    End   Function    
    </SCRIPT>    
   
    接下來在JScript代碼中就可以像普通JScript函數一樣調用Formatvalue()了。用類似的方法也可以實現VBScript代碼調用JScript函數。    
   
    應用同樣的規則,我們可以在任何腳本內調用任何用戶定義函數。不過,從JScript腳本內調用一個不帶參數的VBScript過程(Sub)時應略加注意,此時在JScript中應該像調用一個不帶參數的JScript函數一樣調用它,如用foo()調用VBScript   Sub   foo過程。    
   
    三、數據共享    
   
    在某些情形下混合運用VBScript和JScript函數是非常有用的,但在不同語言腳本之間共享數據也可能很有用。實現這種共享的方法很簡單:不管使用的是什麼語言,只要是在頁面級聲明的變量就可以任意引用。    
   
    對象的使用方法也相似,可以任意選用合適的語言讀取、修改屬性或調用對象的方法。當然給定對象的屬性和方法是由創建該對像實例的語言所定義的。正如上例VBScript的過程調用,當從JScript中調用一個不帶參數的VBScript對象的方法時,其調用方法也遵從JScript的調用規則,反之亦然。    
   
    四、數組管理    
   
    數組共享問題稍微複雜一點。雖然數組也像其它變量一樣可以在不同語言腳本之間共享,但必須注意兼容方面的問題。    
   
    VBScript數組在JScript下可以用VBScript的符號引用,即用myArray(2)引用數組元素而不是JScript的數組元素引用符號myArray[2]。此外,還可以使用一個特殊的JScript對像——VBArray對像將VBScript數組轉換為JScript數組。下面的代碼從VBScript數組myVBArray創建JScript數組myJSArray:    
   
   var   Temp   =   new   VBArray(myVBArray)    
   var   myJSArray    
   myJSArray   =   Temp.toArray()    
   
    上述代碼首先創建一個臨時的VBArray對象,然後使用它的toArray()方法將自己轉換為JScript數組。此後就可以像普通JScript數組一樣使用myJSArray,如myJSArray[1]。但應當注意的是,toArray()方法將把一個多維的VBArray轉換為一維的JScript數組。    
   
    從VBScript中引用JScript數組更為複雜。雖然在VBScript中我們可以直接訪問JScript數組相關的方法和屬性,但沒有直接訪問JScript數組的單個元素的方法。也就是說,我們可以在VBScript腳本中讀取JScript數組的長度屬性,如下所示:    
   
    x   =   myJSArray.length    
   
    但無法直接讀取該數組的單個元素,下面的VBScript代碼是不正確的:    
   
    x   =   myJSArray(3)    
   
    解決該問題的一個可行的方法是執行一個轉換過程,如下面的代碼所示,此處假定VBScript是缺省的腳本語言:    
   
  <%    
    Dim   Temp    
    Dim   myVBArray    
    Temp   =   myJSArray.join(",   ")    
    myVBArray   =   Split(Temp,   ",   ")    
  %>    
   
    此處的JScript   join()方法將數組myJSArray元素轉換到一個以逗號為分割符的字符串,VBScript   Split()函數將字符串轉換為VBScript數組。注意這裡我們是在VBScript環境下調用JScript的join方法。依照此例,我們可以通過自定義VBScript函數來模擬JScript的VBArray對象的toArray()方法以實現JScript數組到VBScript數組的轉換。    


程式碼工作室
ERP/EIP/CMS/CHART/REPORT/SPC/EDA/雲端 系統開發整合
ASP/PHP/JSP/ASP.NET 網頁設計
技術指導顧問
信箱:paulwu0114@gmail.com
http://www.coding.com.tw

2011年9月19日 星期一

How to detect a visitor's IP address

Every visitor to your site or web application has an IP address. It is quite handy to be able to get that address. It can be used for security logging, or perhaps tracing. It can also be used to determine where they are in the world, or at least where their ISP is.
The difficulty is when they're behind a proxy of some sort, you only see the IP address of the proxy server. So, here are the code snippets in PHP,JSP, ASP and .Net that first check for an IP addresses that's forwarded from behind a proxy, and if there's none then just get the IP address.
  • PHP without Proxy detection
    <? $ipaddress = getenv(REMOTE_ADDR); ?>
  • PHP with Proxy detection
    <?if (getenv(HTTP_X_FORWARDED_FOR)) {
    $ipaddress = getenv(HTTP_X_FORWARDED_FOR);
    } else {
    $ipaddress = getenv(REMOTE_ADDR); }
    ?>
  • ASP without Proxy detection
    <%
    ipaddress = Request.ServerVariables("REMOTE_ADDR")
    %>
  • ASP with Proxy detection
    <%
    ipaddress = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
    if ipaddress = "" then
    ipaddress = Request.ServerVariables("REMOTE_ADDR")
    end if
    %>
  • JSP without Proxy detection
    <%
    String ipaddress = request.getRemoteAddr();
    %>
  • JSP with Proxy detection
    <%
    if (request.getHeader("HTTP_X_FORWARDED_FOR") == null) {
    String ipaddress = request.getRemoteAddr();
    } else {
    String ipaddress = request.getHeader("HTTP_X_FORWARDED_FOR");
    }
    %>
我想了解如何获得IP地址的客户端,即访问我的网页。
内容的JSP页面:
<%  
out.print( request.getRemoteAddr() + "<br>"); 
out.print( request.getRemoteHost() );  
%> 
输出:
0:0:0:0:0:0:0:1 
0:0:0:0:0:0:0:1