2013年7月27日 星期六

asp.net web.config example

web.config

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
 
  <system.web>

    <!--  動態偵錯編譯
          設定 compilation debug="true" 會將偵錯符號 (.pdb 資訊) 插入編譯的網頁。
          這樣將會建立較大的檔案並使執行速度變慢。
          一般只在偵錯時將這個值設為 true,其他情況都設為 false。
          如需詳細資訊,請參閱偵錯 ASP.NET 檔案相關的文件。
    -->
    <compilation defaultLanguage="vb" debug="true" />

    <!--  自訂錯誤訊息
          設定 customErrors mode="On" 或 "RemoteOnly" 來啟用自訂錯誤訊息,"Off" 則為停用。
          請對每個您要處理的錯誤,加入相對應的 <error> 標記。

          "On" 永遠顯示自訂 (易讀) 訊息。
          "Off" 永遠顯示詳細的 ASP.NET 錯誤資訊。
          "RemoteOnly" 僅顯示自訂 (易讀) 訊息給不在區域 Web 伺服器上的使用者。
           針對安全性目的,建議您使用這項設定,
           這樣子您就不會將應用程式的詳細資訊顯示給遠端用戶端。
    -->
    <customErrors mode="RemoteOnly" />

    <!--  驗證
          這個區段將設定應用程式的驗證原則。可能的模式包括 "Windows"、
          "Forms"、"Passport" 與 "None"

          "None" 沒有執行任何的驗證。
          "Windows" IIS 會根據其針對應用程式所做的設定來執行驗證 (基本、摘要式或整合式 Windows 驗證)
           IIS 的匿名存取功能必須停用。
          "Forms" 提供自訂表單 (網頁) 讓使用者輸入他們的憑證,
           然後在應用程式中驗證其憑證。使用者憑證 Token 儲存在 Cookie 中。
          "Passport" 驗證是經由 Microsoft 所提供的中央驗證服務而執行,
           此中央驗證服務可替成員網站提供單一登入與核心設定檔服務。
    -->
    <authentication mode="Forms">
       <forms name = ".BASICFORMSAUTH" path="/" loginUrl="Login.aspx" protection="All" timeout="30" >
       </forms>
    </authentication>

    <!--  授權
          這個區段將設定應用程式的授權原則。您可以允許或拒絕不同使用者或角色存取應用程式資源。
          萬用字元: "*" 代表所有的人、"?" 代表匿名 (未驗證的) 使用者。
    -->
    <authorization>
       <deny users = "?" />

            <!--  <allow     users="[使用逗號分隔的使用者清單]"
                             roles="[使用逗號分隔的角色清單]"/>
                  <deny      users="[使用逗號分隔的使用者清單]"
                             roles="[使用逗號分隔的角色清單]"/>
            -->
    </authorization>

    <!--  應用程式層級追蹤記錄
          應用程式層級追蹤啟用應用程式中每一頁面的追蹤記錄檔輸出。
          設定 trace enabled="true" 將啟用應用程式追蹤記錄。如果 pageOutput="true",追蹤資訊將顯示
          在每一頁面的下方。此外,您也可以從 Web 應用程式的根目錄透過瀏覽 "trace.axd" 頁面的方式來檢視
          應用程式的追蹤記錄檔。
    -->
    <trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" />


    <!--  工作階段狀態設定
          根據預設,ASP.NET 會使用 Cookie 來識別哪些要求是屬於某個特定工作階段。
          如果無法使用 Cookie,您也可以將工作階段識別項加入到 URL 來追蹤工作階段。
          若要停用 Cookie,請設定 sessionState cookieless="true"。
    -->
    <sessionState
            mode="InProc"
            stateConnectionString="tcpip=127.0.0.1:42424"
            sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes"
            cookieless="false"
            timeout="20"
    />

    <!--  全球化設定
          此區段用來設定應用程式全球化選項。
    -->
    <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
 
  </system.web>

</configuration>


xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xx Tom cat web.xml
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Sample web.xml File

The following sample web.xml deployment descriptor shows how to declare the HelloServlet servlet in the HelloWorld Web application. See also Description of the web.xml File.
<?xml version="1.0" encoding="ISO-8859-1" ?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
    version="2.4">

    <display-name>HelloWorld Application</display-name>
    <description>
        This is a simple web application with a source code organization
        based on the recommendations of the Application Developer's Guide.
    </description>

    <servlet>
        <servlet-name>HelloServlet</servlet-name>
        <servlet-class>examples.Hello</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>HelloServlet</servlet-name>
        <url-pattern>/hello</url-pattern>
    </servlet-mapping>

</web-app>     

Description of the web.xml File

In the preceding web.xml deployment descriptor file, the <servlet> XML element declares the HelloServlet, the examples.Hello Java class implements the servlet, and the <servlet-mapping> XML element specifies the/hello URL pattern that invokes the servlet in a browser. This URL pattern is used in the index.html file.




沒有留言:

張貼留言