2013年6月14日 星期五

不同area 存在相同名稱的 controller 造成無法呼叫action

錯誤訊息如下:
找到多個與名稱為 'Product' 的控制器相符的型別。如果服務此要求 ('{controller}/{action}/{id}') 的路由沒有指定命名空間以搜尋符合該要求的控制器,就會發生這個情況。在這種情況下,請呼叫可接受 'namespaces' 參數的 'MapRoute' 方法的多載來註冊此路由。

解法:
RouteConfig.RegisterRoutes 指定namespace
routes.MapRoute(
                "Default",
                "{controller}/{action}/{id}",
                new { controller = "Home", action = "Index", id = UrlParameter.Optional },
                new[] { "erpweb.Controllers" }
            );

2013年6月11日 星期二

如何讓server 產生的空白字元傳換成網頁上的空白

將空白字元取代成 \xA0

說明:
nbsp in html corresponds to "\xA0" as a C# string, so use this instead of spaces, when HTML encoded it will produce nbsp

Entity Framework 建立新物件並儲存後馬上取得關聯資料

使用 CreateProxy 建立物件,不要直接 new var newmodel = _contextXXX.CreateProxy<yyy>(); ... _contextXXX.yyy.Add(newmodel); await _contextXXX.SaveC...