2014年7月15日 星期二

[.NET ASP] 根治錯誤

from : http://blog.csdn.net/nileel/article/details/3519744


編譯完項目,訪問,經常出現“配置錯誤”,行***<add assembly="*"/>,某“DLL”文件拒绝访问。重启IIS也不行,重新编译也不对,基本每天都能遇到,频繁的时候编译一次遇到一次。狠狠的百度了一番,终于明白了。原来是windows的索引服务在搞鬼。windows的索引服务对asp.net的临时目录编制索引时,锁定了临时文件的访问权限,因此报错!
知道了原因,就好辦了

最簡單的解決辦法就是禁用索引服務,但是影響比較大。
可以刪除的PDB文件,但是調試的時候不方便
最後我採用的解決辦法是:
配置ASP.net的臨時目錄不受索引服務服務的影響的步驟如下:

1,開始 - 管理工具 - 計算機管理(Win2003的的位置,其他操作系統類似)打開計算機管理
2、展开计算机管理左边树中“服务和应用程序”节点,再在其下展开“索引服务”节点,再在其下展开“System”节点,再在其下展开“目录”节点。
3,在計算機管理的右邊我們可以看到配置的索引服務目錄。
4,在“目錄”節點上右擊鼠標,選擇“新建” - “目錄”
5,在“添加目錄”對話框中,路經輸入框中輸入ASP.net的臨時文件目錄默認應該是:
C :/ WINDOWS/Microsoft.NET/Framework/v1.1.4322/Temporary ASP.NET Files文件/
6,在“包含在索引中嗎?”選項中,選擇“否”
7,單擊“確定”按鈕
8,在“索引服務”節點上右鍵單擊,重起索引服務即可。



















2014年7月7日 星期一

[C#] 如何取得 Request URL 的各個部分


from寶哥  http://blog.miniasp.com/post/2008/02/10/How-Do-I-Get-Paths-and-URL-fragments-from-the-HttpRequest-object.aspx


底下這張表就是各種跟 Browser Request 的網址相關的屬性與用法:


網址:http://localhost:1897/News/Press/Content.aspx/123?id=1#toc
Request.ApplicationPath/
Request.PhysicalPathD:\Projects\Solution\web\News\Press\Content.aspx
System.IO.Path.GetDirectoryName(Request.PhysicalPath)D:\Projects\Solution\web\News\Press
Request.PhysicalApplicationPathD:\Projects\Solution\web\
System.IO.Path.GetFileName(Request.PhysicalPath)Content.aspx
Request.CurrentExecutionFilePath/News/Press/Content.aspx
Request.FilePath/News/Press/Content.aspx
Request.Path/News/Press/Content.aspx/123
Request.RawUrl/News/Press/Content.aspx/123?id=1
Request.Url.AbsolutePath/News/Press/Content.aspx/123
Request.Url.AbsoluteUrihttp://localhost:1897/News/Press/Content.aspx/123?id=1
Request.Url.Schemehttp
Request.Url.Hostlocalhost
Request.Url.Port1897
Request.Url.Authoritylocalhost:1897
Request.Url.LocalPath/News/Press/Content.aspx/123
Request.PathInfo/123
Request.Url.PathAndQuery/News/Press/Content.aspx/123?id=1
Request.Url.Query?id=1
Request.Url.Fragment 
Request.Url.Segments/
News/
Press/
Content.aspx/
123






[SQL] NOT IN clause and NULL values


from:http://stackoverflow.com/questions/129077/not-in-clause-and-null-values


當下NOT IN時,括號裡面的值含有NULL,就會甚麼都撈不到

因為null不等於任何值

null也不等於null

所以,下NOT IN時,建議將null過濾掉 WHERE *** IS NOT NULL


A: select 'true' where 3 in (1, 2, 3, null)
B: select 'true' where 3 not in (1, 2, null)


Query A is the same as:
select 'true' where 3 = 1 or 3 = 2 or 3 = 3 or 3 = null
Since 3 = 3 is true, you get a result.
Query B is the same as:
select 'true' where 3 <> 1 and 3 <> 2 and 3 <> null
When ansi_nulls is on, 3 <> null is UNKNOWN, so the predicate evaluates to UNKNOWN, and you don't get any rows.
When ansi_nulls is off, 3 <> null is true, so the predicate evaluates to true, and you get a row.
zh-CN → zh-TW
,下

2014年7月6日 星期日

[C#] KeyValue 代碼表

from: http://www.cnblogs.com/manongxiaobing/archive/2012/11/05/2755412.html



  鍵盤按鍵 - 對應的代碼
backspace8
tab9
enter13
shift16
ctrl17
alt18
pause/break19
caps lock20
escape27
page up33
Space32
page down34
end35
home36
arrow left37
arrow up38
arrow right39
arrow down40
insert45
delete46
048
149
250
351
452
553
654
755
856
957
a65
b66
c67
d68
e69
f70
g71
h72
i73
j74
k75
l76
m77
n78
o79
p80
q81
r82
s83
t84
u85
v86
w87
x88
y89
z90
left window key91
right window key92
select key93
numpad 096
numpad 197
numpad 298
numpad 399
numpad 4100
numpad 5101
numpad 6102
numpad 7103
numpad 8104
numpad 9105
multiply106
add107
subtract109
decimal point110
divide111
f1112
f2113
f3114
f4115
f5116
f6117
f7118
f8119
f9120
f10121
f1










2014年6月26日 星期四

.NET MVC 筆記


MVC筆記

規劃兩個月製作MVC簡報,也告一段落了,紀錄其他延伸閱讀的筆記



ASP.NET MVC使用筆記
http://catchtest.pixnet.net/blog/post/29156132-asp.net-mvc%E4%BD%BF%E7%94%A8%E7%AD%86%E8%A8%98


格式化 Javascript
http://www.css88.com/tool/js_beautify/


ASP.NET MVC專案最佳化
http://blog.kkbruce.net/2013/07/asp-net-mvc-project-performance-security-up-tips.html#.U5_1ZvmSylA


確保傳輸資料的安全
http://ithelp.ithome.com.tw/question/10137427


使用输出缓存提高性能
http://www.360doc.com/content/11/0303/22/6101874_97895851.shtml


ASP.NET性能優化之讓瀏覽器緩存動態網頁

http://rritw.com/a/bianchengyuyan/_NET/20110915/128804.html


黑暗執行序 - ASP.NET MVC路由練習-API分版
http://blog.darkthread.net/post-2013-09-16-aspnet-mvc-versioning-via-routing.aspx



快快樂樂學LINQ系列
http://www.dotblogs.com.tw/hatelove/category/6084.aspx


如何提昇LINQ 的效能!?
http://flashlin.wordpress.com/2009/03/24/%E5%A6%82%E4%BD%95%E6%8F%90%E6%98%87linq-%E7%9A%84%E6%95%88%E8%83%BD/


ADO.Net Entity Framework : (二十) 提升EF執行速度方法
http://www.dotblogs.com.tw/asdtey/archive/2009/10/28/efimproveperformance.aspx?fid=58201




2014年6月23日 星期一

一般View與Partial View有什麼不同呢?



from : http://arthurmvc.blogspot.tw/2012/11/aspnet-mvcview.html


在上一章中,我曾提到過有關Controller的命名會受到限制,所有Controller都必需是Controller這幾個英文字作為結尾,同理可知,想必這裡應該也是在命名原則上作文章,是的!在View中若是以底線作為檔案名稱開頭的View,其意義就是這個View是一種Partial View!

    一般View與Partial View有什麼不同呢?
   我可以把它想作成:一般View是一個我們預期它為一個既完整又是最終的畫面呈現,而Partial View是畫中的某一部份。有的時候,一個View太過巨大在設計及維護上有著很高的障礙,為了避免太過複雜而讓自己陷入設計的泥淖,通常,會將一個View中的某幾個部份獨立出來成為Partial View。在本文前面所述,在專案的開發過程中,有的時候我們會發現某些頁面會有一個共同的部份,這個時候通常我們也會將其共同的部份切割出來成為一個Partial View並放置在Views/Share資料夾中共用。





2014年6月20日 星期五

[MVC] - ViewBag 裡使用方法(Method)

from: http://kevintsengtw.blogspot.tw/2012/04/aspnet-mvc-3viewbag-method.html#.U6QCbPmSylA



        //
        // GET: /ViewDataBag/
        public ActionResult func()
        {
            ViewData["func1"] = DateTime.Now;
            ViewBag.func1 = new Func<int, string>(GetStr);

            return View();
        }

        private string GetStr(int iNumber)
        {
            if (iNumber >= 60)
            {
                return iNumber.ToString() + " 及格";
            }
            else
            {
                return iNumber.ToString() + " 不及格";
            }
        }











2014年6月19日 星期四

[MVC] 停止瀏覽器快取網頁 for ASP.NET


From  http://jhshen.blogspot.tw/2010/07/for-aspnet-mvc.html



瀏覽器為了加速網頁讀取,通常會採用快取,
所以使用者登出後,按下"回上一頁"幾乎都可以看到登出前瀏覽過的資料。
要避免使用者登出後使用"回上一頁"功能,最簡單的方式就是讓頁面不被快取,
在網路上找了一些方法,都是在<head></head>裡面加上:
//將網頁設為立即過期。
<meta http-equiv="Expires" content="0" />
//舊寫法,為了增加相容性。
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache" />
<meta http-equiv="Pragma-directive" content="no-cache" />
<meta http-equiv="Cache-Directive" content="no-cache" />

不過這樣做,不知道為什麼在 IIS 6 的環境上,執行 ASP.NET MVC 的 Web Application 還是可以讓使用者按下"回上一頁"...
後來發現也可以直接加在 http response headers 上,
因此,改寫了一下專案裡面 base Controller 在 Initialize 時,設定 Response 的 cache 設定,設定如下:
protected override void Initialize(RequestContext requestContext)
{
    base.Initialize(requestContext);

    requestContext.HttpContext.Response.Cache.SetCacheability(HttpCacheability.NoCache);
    requestContext.HttpContext.Response.Cache.SetExpires(DateTime.MinValue);
    requestContext.HttpContext.Response.Cache.SetNoStore();
}





2014年6月17日 星期二

[chrome] network 時間說明



from
http://stackoverflow.com/questions/10537399/what-does-the-times-mean-in-google-chromes-timeline-in-the-network-panel




  • DNS lookup: Time spent performing the DNS lookup. (you need to find out IP address of site.com and this takes time)
  • Blocking: Time the request spent waiting for an already established connection to become available for re-use. As was said in another answer it does not depend on your server - this is client's problem.
  • Connecting: Time it took to establish a connection, including TCP handshakes/retries, DNS lookup, and time connecting to a proxy or negotiating a secure-socket layer (SSL). Depends on network congestion.
  • Sending - Time spent sending the request. Depends on the size of sent data (which is mostly small because your request is almost always a few bytes except if you submit a big image or huge amount of text), network congestion, proximity of client to server
  • Waiting - Time spent waiting for the initial response. This is mostly the time of your server to process and respond to your response. This is how fast if your server calculating things, fetching records from database and so on.
  • Receiving - Time spent receiving the response data. Something similar to the sending, but now you are getting your data from the server (response size is mostly bigger than request). So it also depends on the size, connection quality and so on.



  • chrome官方文件

    https://developer.chrome.com/devtools/docs/network



    2014年6月15日 星期日

    [MVC] Two Html.ActionLink in a column using WebGrid

    form http://forums.asp.net/t/1653111.aspx?Two+Html+ActionLink+in+a+column+using+Webgrid



    columns: grid.Columns(
    
    
    grid.Column("id"),
    grid.Column("Name"),
    grid.Column(header: "Actions", format: (item) =>
         new HtmlString(
               Html.ActionLink("Edit", "Edit", new { id = item.id } ).ToString()  +
               Html.ActionLink("Delete", "Delete", new { id = item.id } ) .ToString()
         )
    )
    )







     

    MangoHost Copyright © 2009 Cookiez is Designed by Ipietoon for Free Blogger Template