發表文章

目前顯示的是有「ASP.NET MVC」標籤的文章

SqlException: The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value. The statement has been terminated.

圖片
  The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value. The statement has been terminated. Ref: https://blog.csdn.net/weixin_44728363/article/details/88948049 https://stackoverflow.com/questions/18557546/why-i-cant-save-the-current-datetime-now-using-entity-framework

ASP.NET MVC第017天_控制器層級_Action層級的登入授權控管

圖片
  後台系統呈現相關的控制器請求 預設若沒有設置[Authorize] 那登入等同於虛設 使用者可直接URL敲打就能直接連進後台了 可針對 控制器層級 或者 Action層級 上方配置[Authorize] 來限制只允許登入後(有系統存取權限者)才能瀏覽後台 若其中一組Action 配置更為[AllowAnonymous] 則代表允許該頁可不用登入後才能存取 有配置好則會在我們預設有擴充 判定沒登入的人強制跳轉到登入頁

ASP.NET MVC第023天_Ajax Helper_Ajax.RouteLink使用筆記part3

圖片
Ajax.RouteLink() 跟 Ajax.ActionLink() 兩者皆為產生出超連結的 <a> tag 只不過產生方式不同 Ajax.RouteLink() 別於 Ajax.ActionLink()  可支援直接設置特定Controller跟Action 是只可以透過設置路由模板名稱(路由虛擬路徑)的方式進行 以下是Ajax.RouteLink()的多載 public static MvcHtmlString RouteLink(this AjaxHelper ajaxHelper, string linkText, string routeName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, IDictionary<string, object> htmlAttributes); public static MvcHtmlString RouteLink(this AjaxHelper ajaxHelper, string linkText, object routeValues, AjaxOptions ajaxOptions); public static MvcHtmlString RouteLink(this AjaxHelper ajaxHelper, string linkText, object routeValues, AjaxOptions ajaxOptions, object htmlAttributes); public static MvcHtmlString RouteLink(this AjaxHelper ajaxHelper, string linkText, RouteValueDictionary routeValues, AjaxOptions ajaxOptions); public static MvcHtmlString RouteLink(this AjaxHelper ajaxHelper, string linkText, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, IDictionary<string, object...

ASP.NET MVC第022天_Ajax Helper_Ajax.BeginForm使用筆記part2

圖片
Ajax.BeginForm() 主要是微軟封裝好用來實踐異步表單提交的一項擴充幫助方法  以下為其11種多載method各自不同簽章 public static MvcForm BeginForm(this AjaxHelper ajaxHelper, string actionName, string controllerName, AjaxOptions ajaxOptions); public static MvcForm BeginForm(this AjaxHelper ajaxHelper, string actionName, string controllerName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, IDictionary<string, object> htmlAttributes); public static MvcForm BeginForm(this AjaxHelper ajaxHelper, string actionName, string controllerName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions); public static MvcForm BeginForm(this AjaxHelper ajaxHelper, string actionName, string controllerName, object routeValues, AjaxOptions ajaxOptions); public static MvcForm BeginForm(this AjaxHelper ajaxHelper, string actionName, RouteValueDictionary routeValues, AjaxOptions ajaxOptions, IDictionary<string, object> htmlAttributes); public static MvcForm BeginForm(this AjaxHelper ajaxHelper, string actionName, string con...

ASP.NET MVC第021天_Ajax Helper_AjaxOptions,AjaxExtensions,ActionLink,InsertionMode使用筆記part1

圖片
  在.net webform開發時代往往只要提到ajax 很直覺會去聯想到的就是局部更新、updatepanel 和一些webform以前要比較細心留意 asp.net ajax生命週期 等等技術的關鍵字 在asp.net mvc 這塊則是需透過ajax helper來實踐 底層是透過jQuery來封裝的 首先我們新增好一個.net framework的 mvc5專案 預設要先從nuget補安裝好 跟ajax相關的jQuery Microsoft.jQuery.Unobtrusive.Ajax 跟ajax驗證相關的jQuery Microsoft.jQuery.Unobtrusive.Validation 至布局頁加上全域性ajax相關的 js引入 一定要比照此上下順序(因有前後依賴) <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script> <script src="~/Scripts/jquery.validate.min.js"></script> <script src="~/Scripts/jquery.validate.unobtrusive.min.js"></script> AjaxOptions的介紹 在asp.net MVC中要達成一些ajax設定主要就是透過此class 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 8...