Top Banner
1 活活活活活活 活活活 1
25

活動網站分享

Oct 28, 2014

Download

Technology

Siu-On Tom

2014/4/11 多奇內部分享
對目前做過的專案中,有使用到的技術、問題做分享。
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 活動網站分享

1

活動網站分享

譚兆安

1

Page 2: 活動網站分享

All services from your imperative.

/232

• DisplayModeProvider • audiojs• Fastclick• 注意事項• 其他

議程

Page 3: 活動網站分享

All services from your imperative.

/233

DisplayModeProvider

Page 4: 活動網站分享

All services from your imperative.

/234

DisplayModeProvider

根據 User-Agent 顯示對應的 View

Page 5: 活動網站分享

All services from your imperative.

/235

DisplayModeProvider

http://detectmobilebrowsers.com/

Page 6: 活動網站分享

All services from your imperative.

/236

DisplayModeProvider

Page 7: 活動網站分享

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))))});

Page 8: 活動網站分享

All services from your imperative.

/238

DisplayModeProvider

Page 9: 活動網站分享

All services from your imperative.

/239

audiojs

Page 10: 活動網站分享

All services from your imperative.

/2310

audiojs

讓不支援 HTML5 Audio Tag 的瀏覽器可以播放音效

Page 11: 活動網站分享

All services from your imperative.

/2311

audiojs

http://caniuse.com/

Page 12: 活動網站分享

All services from your imperative.

/2312

audiojs

http://kolber.github.io/audiojs/不支援 .ogg

Page 13: 活動網站分享

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>

Page 14: 活動網站分享

All services from your imperative.

/2314

fastclick

Page 15: 活動網站分享

All services from your imperative.

/2315

fastclick

移除手機瀏覽器的 300ms delay 限制

Page 16: 活動網站分享

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>

Page 17: 活動網站分享

All services from your imperative.

/2317

注意事項

Page 18: 活動網站分享

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';

Page 19: 活動網站分享

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 驗證時,要注意後台的判斷

Page 20: 活動網站分享

All services from your imperative.

/2320

注意事項

• 使用 Elmah 時,建議使用 XML Log的方式,當出現資料庫出現連線問題時,才有記錄去偵錯

Page 21: 活動網站分享

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>

Page 22: 活動網站分享

All services from your imperative.

/2322

注意事項

• 使用無 NuGet 安裝的組件時,要記得手動加入版控

Page 23: 活動網站分享

All services from your imperative.

/2323

其他

• 在這次開發過程中遇到一個 DB 問題:交易記錄檔已滿

Page 24: 活動網站分享

All services from your imperative.

/2324

其他

• 在這次開發過程中遇到一個 DB 問題:交易記錄檔已滿

原因: Server 硬碟空間滿了…

Page 25: 活動網站分享

All services from your imperative.

感謝各位