1 活活活活活活 活活活 1
Oct 28, 2014
1
活動網站分享
譚兆安
1
All services from your imperative.
/232
• DisplayModeProvider • audiojs• Fastclick• 注意事項• 其他
議程
All services from your imperative.
/233
DisplayModeProvider
All services from your imperative.
/234
DisplayModeProvider
根據 User-Agent 顯示對應的 View
All services from your imperative.
/235
DisplayModeProvider
http://detectmobilebrowsers.com/
All services from your imperative.
/236
DisplayModeProvider
All services from your imperative.
/237
DisplayModeProvider
using System.Web.WebPages;
Global.asax Application_Start
Regex b = new Regex(@"Detect Regex", RegexOptions.IgnoreCase | RegexOptions.Multiline);Regex v = new Regex(@"Detect Regex", RegexOptions.IgnoreCase | RegexOptions.Multiline);
DisplayModeProvider.Instance.Modes.Insert(0, new DefaultDisplayMode("Mobile"){ ContextCondition = (context => (b.IsMatch(context.Request.ServerVariables["HTTP_USER_AGENT"]) ||
v.IsMatch(context.Request.ServerVariables["HTTP_USER_AGENT"].Substring(0, 4))))});
All services from your imperative.
/238
DisplayModeProvider
All services from your imperative.
/239
audiojs
All services from your imperative.
/2310
audiojs
讓不支援 HTML5 Audio Tag 的瀏覽器可以播放音效
All services from your imperative.
/2311
audiojs
http://caniuse.com/
All services from your imperative.
/2312
audiojs
http://kolber.github.io/audiojs/不支援 .ogg
All services from your imperative.
/2313
audiojs
<script src="@Url.Content("~/Scripts/audiojs/audio.min.js")"></script>
<script> var as;
if (typeof Audio === 'undefined') { audiojs.events.ready(function () { as = audiojs.createAll(); }) };</script>
All services from your imperative.
/2314
fastclick
All services from your imperative.
/2315
fastclick
移除手機瀏覽器的 300ms delay 限制
All services from your imperative.
/2316
fastclick
https://github.com/ftlabs/fastclick
<script type="text/javascript" src="@Url.Content("~/Scripts/fastclick.js")"></script>
<script> $(function() { FastClick.attach(document.body); });</script>
All services from your imperative.
/2317
注意事項
All services from your imperative.
/2318
注意事項
• 使用 facebook 登入時,用轉頁的方式window.location.href = 'https://www.facebook.com/dialog/oauth?client_id=FacebookAPIKey&scope=email,user_about_me,user_likes,publish_actions
&state=code&redirect_uri=WebSiteUrl';
All services from your imperative.
/2319
注意事項
• 使用 facebook 登入時,用轉頁的方式window.location.href = 'https://www.facebook.com/dialog/oauth?client_id=FacebookAPIKey&scope=email,user_about_me,user_likes,publish_actions&state=code&redirect_uri=WebSiteUrl';
• 前後台在同一網站下,且都使用 FormsAuthentication 寫 cookie 驗證時,要注意後台的判斷
All services from your imperative.
/2320
注意事項
• 使用 Elmah 時,建議使用 XML Log的方式,當出現資料庫出現連線問題時,才有記錄去偵錯
All services from your imperative.
/2321
注意事項
• Web.Config 加入 ipSecurity ,限定特定 IP 讀取 Elmah
http://www.iis.net/configreference/system.webserver/security/ipsecurity
<location path="elmah.axd" inheritInChildApplications="false"> <system.webServer> <security> <ipSecurity allowUnlisted="false"> <add ipAddress="127.0.0.1" subnetMask="8" allowed="true" /> <add ipAddress="192.168.2.0" subnetMask="24" allowed="true" /> <add ipAddress="58.86.49.32" subnetMask="27" allowed="true" /> <add ipAddress="61.62.220.19" subnetMask="32" allowed="true" /> </ipSecurity>
</security>
All services from your imperative.
/2322
注意事項
• 使用無 NuGet 安裝的組件時,要記得手動加入版控
All services from your imperative.
/2323
其他
• 在這次開發過程中遇到一個 DB 問題:交易記錄檔已滿
All services from your imperative.
/2324
其他
• 在這次開發過程中遇到一個 DB 問題:交易記錄檔已滿
原因: Server 硬碟空間滿了…
All services from your imperative.
感謝各位