Spiga

2009/08/15 雙溪福隆東北角單車行

今天早上太晚起床了,一直拖到 8:40AM 才出門,這次的行程是走汐平路去平溪、十分,之前已經騎車去過好幾次了 (2008/12/28 汐止-平溪 單車挑戰、2009/04/28 汐平路-106縣道 單車行),不過這次要在十分這邊走台2丙線去雙溪、福隆,然後走北海岸回汐止,全程差不多是 100 公里,難得在十分車站剛好看到有火車,而且還兩列哩:
SANY0025##ReadMore##

也不知道為什麼,台2丙線竟然沒什麼車,連在隧道內也是一樣,這樣也好,騎起來也安心一點。
SANY0028SANY0030

在雙溪倒是有不少人租自行車來騎,沿途還有讓遊客休息的棚子,還可以蓋記念章呦,只是一路都沒有樹蔭,非常的熱。
SANY0031
SANY0035SANY0032
SANY0037SANY0036

到雙溪市區就隨便在 7-11 吃碗涼麵和飲料,也補充了水,就繼續往福隆前進,不過由於是中午時間,太陽實在是太毒了,中途只好找個路邊的涼亭小睡一下,恢復體力。

SANY0041SANY0040

在台2丙線的終點有一間加油站,問了一下加油站的員工東北角要往那一邊走,結果他說右邊,沒想到就跑去福隆海水浴場了,再走下去不就要去宜蘭了,然後再由北宜回汐止 ?! No! No! No! 今天時間不夠,改天吧。於是折返往鼻頭角前進。
SANY0047
SANY0044SANY0045
SANY0042

疑 ?! 這兩個人是怎麼跑到礁石上去釣魚的哩 ?!
SANY0050
SANY0049SANY0048  

最後經由瑞芳回汐止,這條路之前 2009/04/18 無耳茶壺山單車行 有走過,只不過是反向走。

軌跡圖:
軌跡圖

高度表:
高度表

速度表:
速度表

碼錶資訊:
SANYO DIGITAL CAMERASANYO DIGITAL CAMERA
SANYO DIGITAL CAMERASANYO DIGITAL CAMERA

  • 總時間: 8:40AM ~ 05:20PM
  • 總騎乘時間: 8 小時 40 分
  • 總騎乘距離: 98.11 公里
  • 最高時速: 52.6 公里/小時
  • 平均時速: 16.2 公里/小時
  • 如何加密字串

    聖哥寫了一組副程式,可以用來將字串加密後 (使用 3DES 加密法),再轉成 Base64 字串,很適合使用在 web.config 中儲存一些重要資料,例如連線字串。

    其中的 key 和 iv 兩個參數必須是 128bit 的資料,也就是長度是 16 的 byte 陣列。##ReadMore##

    using System.Security.Cryptography
    using System.Text

    public string EncryptString(string s, byte[] key, byte[] iv)
    {
    TripleDESCryptoServiceProvider provider =
    new TripleDESCryptoServiceProvider();
    CryptoAPITransform encryptor = provider.CreateEncryptor(key, iv);

    UTF8Encoding utf8 = new UTF8Encoding();
    byte[] source = utf8.GetBytes(s);
    byte[] target = encryptor.TransformFinalBlock(source, 0, source.Length);

    return Convert.ToBase64String(target);
    }

    public string DecryptString(string s, byte[] key, byte[] iv)
    {
    TripleDESCryptoServiceProvider provider =
    new TripleDESCryptoServiceProvider();
    CryptoAPITransform decryptor = provider.CreateDecryptor(key, iv);

    UTF8Encoding utf8 = new UTF8Encoding();
    byte[] source = Convert.FromBase64String(s);
    byte[] target = encryptor.TransformFinalBlock(source, 0, source.Length);

    return utf8.GetString(target);
    }

    如何讓 MOSS 支援 AJAX

    如果要讓 MOSS 支援 AJAX,首先必須先下載 ASP.NET 2.0 AJAX Extensions 1.0 (按 這裡 下載),然後在 MOSS 伺服器上安裝它,安裝完畢之後,接下來要修改 MOSS 網站的 web.config 檔,一般是位於 c:\inetpub\wwwroot\wss\VirtualDirectories\80 資料夾下,也就是當初在建立應用程式時所設定的路徑,如下圖最下面的路徑:
    ##ReadMore##

    1. 在 <configSections> 元素下加入 <sectionGroup> 子元素如下:

    <configSections>
        <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
          <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
              <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
            <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
              <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere" />
              <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
              <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication" />
            </sectionGroup>
          </sectionGroup>
        </sectionGroup>
    </configSections>

    2. 在 <system.web>/<pages> 元素下加入 <controls> 子元素如下:

    <pages>
          <controls>
            <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
          </controls>
    </pages>

     

    3. 在 <compilation> 元素下加入 <assemblies> 子元素如下:

    <assemblies>
           <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </assemblies>

     

    4. 在 <httpHandlers> 區段最後面加入以下 handlers 的註冊:

    <httpHandlers>
          <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
          <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
          <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
    </httpHandlers>

     

    5. 在 <httpModules> 區段中加入以下模組:

    <httpModules>
          <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </httpModules>

     

    6. 在 <SharePoint>/<SafeControls> 區段中加入以下安全控制項註冊:

    <SafeControls>
          <SafeControl Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TypeName="*" Safe="True" />
    </SafeControls>

     

    7. 在 web.config 最後面的 </configuration> 這一行之前加上:

    <system.web.extensions>
        <scripting>
          <webServices>
          <!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. -->
          <!--
            <authenticationService enabled="true" requireSSL = "true|false"/>
          -->
          <!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and writeAccessProperties attributes. -->
          <!--
          <profileService enabled="true"
                          readAccessProperties="propertyname1,propertyname2"
                          writeAccessProperties="propertyname1,propertyname2" />
          -->
          </webServices>
          <!--
          <scriptResourceHandler enableCompression="true" enableCaching="true" />
          -->
        </scripting>
      </system.web.extensions>
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false"/>
        <modules>
          <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
        </modules>
        <handlers>
          <remove name="WebServiceHandlerFactory-Integrated" />
          <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode"
               type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
          <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
          <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
        </handlers>
    </system.webServer>

     

    8. 在主版頁面中加入 ScriptManager 控制項,主版面頁檔位於 \\[你網站網址]\_catalogs\masterpage 資料夾之下,預設檔名是 default.master,在 <WebPartPages:SPWebPartManager> 控制項下一行加入 <asp:ScriptManager> 控制項如下:

    <WebPartPages:SPWebPartManager id="m" runat="Server"/>

    <asp:ScriptManager runat="server" ID="ScriptManager1"></asp:ScriptManager>

     

    9. 接下來你就可以在頁面中或 WebPart 中使用 UpdatePanel 這一類的 AJAX 控制項了。

     

    參考資料: Integrating ASP.NET AJAX with SharePoint

    如何在 MOSS 網頁中使用 C# 程式碼

    在使用 SharePoint Designer 2007 設計 MOSS 2007 的頁面 (.aspx) 時,如果要在頁面中加入 C# 程式碼,例如事件:

    <%@ Page Language="C#" masterpagefile="~masterurl/default.master" title="未命名 1" inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" meta:progid="SharePoint.WebPartPage.Document" %>

    <script type="text/c#" runat="server">

    protected void Button1_Click(object sender, EventArgs e)
    {
    Button1.Text = DateTime.Now.ToString();
    }
    </script>

    <asp:Content id="Content1" runat="server" contentplaceholderid="PlaceHolderMain">

    <asp:Button ID="Button1" runat="server" Height="48px" onclick="Button1_Click"
    Text="Button" Width="308px"/>

    </asp:Content>

    ##ReadMore##

    在執行時會出現以下錯誤訊息:
    image

    這是因為在預設的狀況下,MOSS 不允許在頁面中包含 <script> … </script> 的區塊,要解決這個問題,可以修改網站的 web.config 檔,一般是位於 c:\inetpub\wwwroot\wss\VirtualDirectories\80 資料夾下,也就是當初在建立應用程式時所設定的路徑,如下圖最下面的路徑:
    image

    在 web.config 中找到 <PageParserPaths> 區段,在裡面加入以下設定:

    <PageParserPath VirtualPath="/Pages/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />


    image

    • VirtualPath="/Pages/*" : 設定 /Pages/ 路徑下的所有 .aspx 頁面都要進行程式碼解析。
    • CompilationMode="Always" : 設定每次都要編譯 .aspx 頁面。
    • AllowServerSideScript="true" : 設定 .aspx 頁面中允許出現 <script> … </script> 的程式碼區塊。
    • IncludeSubFolders="true" : 設定包含 VirtualPath 屬性以下的所有子目錄都有相同的設定。

    這樣就可以允許在這個網站下的任何 .aspx 頁面中可以使用 <script> … </script> 的程式碼區塊,就可以撰寫 C# 程式碼了。

    2009/07/11 內湖碧山巖-風櫃嘴單車行

    今天下午和 watermelon 一起從汐止火車站出發,要騎去內湖碧山巖 –> 風櫃嘴 –> 回汐止,雖然特別選下午 4:00PM 出發,可是太陽還是超級毒的,騎了快九公里才到碧山路,就已經熱到爆:
    SANY0001##ReadMore##

    開始爬坡前,matermelon 設定一下 GPS 導航,免得迷路了,我則是心中在 OS : "這會不會太陡了啊 ?"
    SANYO DIGITAL CAMERASANYO DIGITAL CAMERA

    果然沒錯,這一路幾乎都是長陡坡,我覺要比之前 2009/05/23 桐花、熊空單車行 的好漢坡要陡多了,而且距離長多了,真是有夠給它硬斗,一路揮汗如雨,中途甚至買了一瓶 600cc 的運動飲料,直接給它乾了,就知道有多缺水了,還好後來山上有雲有樹蔭,要不然應該會直接掛在半路變人乾了。

    這次戴了新配的防風眼鏡,由於天色暗了,所以半路把鏡片從黑色墨鏡換成夜間使用黃色鏡片,不過看到照片後才發現一整個怪,還是黑色墨鏡比較順眼。爬到內雙溪森林公園,算是中途高點了,差不多海拔 400 公尺,下次可以帶全家來這邊走走:
    SANY0005

    接下來就一路下滑,接到往風櫃嘴的路:
    SANY0006
    SANY0007SANYO DIGITAL CAMERA

    沒想到經過之前碧山巖的嚴酷考驗之後,騎風櫃嘴倒變得比較輕鬆了:
    SANYO DIGITAL CAMERASANYO DIGITAL CAMERA

    回到汐止之後,和 watermelon 一起去他介紹的小吃店吃晚餐,第一次吃豬油乾麵,很好吃哩,下次可以再來吃,也第一次吃雞蛋泡泡冰,很特別,有加生雞蛋卻沒有雞蛋味呦,不過倒讓我懷念起台中一中的豐仁冰了,下星期回台中再來去吃吧。

    軌跡圖:
    軌跡圖

    高度表:
    高度表

    速度表:
    速度表

    今天的碼錶怪怪的,不知道是那裡秀斗了,常常斷訊,所以也就不準了,所幸還有 GPS 軌䟿記錄,所以就不附上碼錶資訊了。