主頁 > .NET開發 > c#購物車功能實作,用戶登錄及收藏功能實作

c#購物車功能實作,用戶登錄及收藏功能實作

2020-09-10 09:25:12 .NET開發

一.思路邏輯:

首先我先來說一下我自己的理解,一個萌新的見解,要實作購物車的功能,首先要獲取到登錄時的用戶id及商品的編號(商品id),這里我用的模式是mvc模式進行實作功能的,用戶登錄時,利用session保存用戶的登錄用戶名,然后在控制器里進行傳值操作,定義一個session進行接收用戶輸入的用戶名,登錄成功后進行保存用戶的用戶名,登錄成功,前臺在進行跳轉到顯示界面,點擊事先創建好的購物車按鈕,把我們已經保存好的用戶名傳過去,在進行session接收用戶名字,添加到購物車時,前面我也說到需要兩個值,我們現在已經獲取到了用戶id(用戶名),再獲取到商品id就可以進行添加到購物車功能的實作,在顯示的ajax拼接字串進行顯示的時候,我們需要再添加一個多選按鈕(多選按鈕是為了進行多項資料選擇時,添加到購物車以及添加收藏時更方便一些),為多選按鈕添加一個id屬性或者name屬性,這里是為了我們方便獲取它的資料,獲取多選框的id值的方法我就不在這里過多介紹了,既然我們需要的兩個值都已經獲取到,我們的添加購物車功能就可以實作了,今天先寫這么多,明天還要周考,在以后的時間里我會繼續修改和添加這篇文章的后續內容,大佬們看過之后,若是有空閑時間,在評論區多給小學生一些建議,我會進行改正的.今天我就說到這里了,購物車的添加基本說完了,后續我會及時利用空閑時間進行后續功能及代碼思路邏輯的更新.

二.代碼如下:

實體化模型層(model層),共創建了四個表,我用的方法是EF架構中的codefirst方法,詳細解釋大家可以百度,或者可以看一看另一個博主的博客,https://www.cnblogs.com/zpyplan/p/9565863.html:

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 using System.ComponentModel.DataAnnotations;
 7 using System.ComponentModel.DataAnnotations.Schema;
 8 
 9 namespace MODEL
10 {
11     //購物車表
12     [Table("MyShoppingCar")]
13     public class MyShoppingCar
14     {
15         [Key]
16         public int  Id { get; set; }
17         public string UserId { get; set; }
18         public string Pno { get; set; }
19         public int? Account { get; set; }
20     }
21 }
MyShoppingCar
 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 using System.ComponentModel.DataAnnotations;
 7 using System.ComponentModel.DataAnnotations.Schema;
 8 
 9 namespace MODEL
10 {
11     //收藏表
12     [Table("MyFavorite")]
13     public class MyFavorite
14     {
15         [Key]
16         public string UserId { get; set; }
17         public string Pno { get; set; }
18     }
19 }
MyFavorite
 1 using System;
 2 using System.Collections.Generic;
 3 using System.ComponentModel.DataAnnotations;
 4 using System.ComponentModel.DataAnnotations.Schema;
 5 
 6 namespace MODEL
 7 {
 8     //商品表
 9     [Table("Product")]
10     public class Product
11     {
12         [Key]
13         public int Id { get; set; }
14         public string Pno { get; set; }
15         public string Pname { get; set; }
16         public int? Price { get; set; }
17         public string ImgPath { get; set; }
18     }
19 }
Product
 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 using System.ComponentModel.DataAnnotations;
 7 using System.ComponentModel.DataAnnotations.Schema;
 8 
 9 namespace MODEL
10 {
11     //登錄用戶表
12     [Table("UserInfo")]
13     public class UserInfo
14     {
15         [Key]
16         public String UserID { get; set; }
17         public String UserName { get; set; }
18         public String WX { get; set; }
19         public String Pwd { get; set; }
20         public String QQ { get; set; }
21     }
22 }
UserInfo

搭建好model層,我們要開始寫dal層里的方法了,我們要實作的功能有用戶登錄功能,商品的顯示功能,添加到購物車功能,加減一功能,收藏功能,顯示購物車串列,批量洗掉購物車

dal層如下(codefirst方法):

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace DAL
 8 {
 9     public class MyFavoriteDAL
10     {
11         public int Favorite(string userid,string pnos)
12         {
13             string[] arr = pnos.Trim(',').Split(',');
14             using (Model1 mc = new Model1())
15             {
16                 foreach (string str in arr)
17                 {
18                     string sql = $"insert into MyFavorite(userid,pno) values('{userid}','{str}')";
19                     mc.Database.ExecuteSqlCommand(sql);
20                 }
21             }
22                 
23             return 1;
24         }
25     }
26 }
MyFavoriteDAL
 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 using MODEL;
 7 
 8 namespace DAL
 9 {
10     public class MyShoppingCarDAL
11     {
12         //添加到購物車的方法
13         public int AddMyShoppingCar(string userid, string pnos)
14         {
15             string[] arr = pnos.Trim(',').Split(',');
16             using (Model1 mc = new Model1())
17             {
18                 foreach (string str in arr)
19                 {
20                     string sql = $"insert into MyShoppingCar(userid,pno,Account) values('{userid}','{str}',1)";
21                     mc.Database.ExecuteSqlCommand(sql);
22                 }
23             }
24 
25             return 1;
26         }
27 
28         //獲取購物車的資訊
29         public List<V_MyShoppingCar> GetList(string userid)
30         {
31             using (Model1 mc = new Model1())
32             {
33 
34                 var query = from s in mc.Products
35                             from t in mc.MyShoppingCars
36                             where s.Pno == t.Pno && t.UserId== userid
37                             select new V_MyShoppingCar { Pno = s.Pno, Pname = s.Pname, Price = s.Price, Id = t.Id, Account = t.Account, TotalMoney = t.Account * s.Price, ImgPath=s.ImgPath };
38                 return query.ToList();
39             }
40         }
41 
42         //批量洗掉
43         public int DelMyShoppingCars(string ids)
44         {
45             //1,2,3,4,....
46             using (Model1 mc = new Model1())
47             {
48                 string sql = $"delete MyShoppingCar where id in({ids.Trim(',')})";
49                 mc.Database.ExecuteSqlCommand(sql);
50             }
51             return 1;
52         }
53 
54         //加減1
55         public int MyShoppingCarsUpDown(string id,string sType)
56         {
57             using (Model1 mc = new Model1())
58             {
59                 string sql;
60                 if (sType.Equals("up"))
61                      sql = $"update MyShoppingCar set Account=Account+1 where id={id}";
62                 else
63                     sql = $"update MyShoppingCar set Account=Account-1 where id={id}";
64                 mc.Database.ExecuteSqlCommand(sql);
65             }
66             return 1;
67         }
68 
69     }
70 }
MyShoppingCarDAL
 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 using MODEL;
 7 
 8 namespace DAL
 9 {
10     public class ProductDAL
11     {
12         //商品顯示的方法
13         public List<Product> GetList(string pname)
14         {
15             using (Model1 mc = new Model1())
16             {
17                 //linq查詢
18                 return mc.Products.Where(x=>x.Pname.Contains(pname)).ToList();
19             }
20         }
21 
22 
23 
24     }
25 }
ProductDAL
 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace DAL
 8 {
 9     public class UserInfoDAL
10     {
11         //用戶登良路的方法
12         public int Login(string userid,string pwd)
13         {
14             using (Model1 mc = new Model1())
15             {
16                //linq查詢的方法
17                return mc.UserInfos.Where(x => x.UserID.Equals(userid) && x.Pwd.Equals(pwd)).Count();
18             }
19         }
20     }
21 }
UserInfoDAL

 

控制器里的方法(因為這里我是搭三層寫的,有個bll層,也就是業務邏輯層,控制器里呼叫的方法大多是呼叫的業務邏輯層的方法,因為我吧所有業務處理的代碼都寫在了dal層,我在這里就不寫bll層了,復制代碼時只需將bll層的方法呼叫替換成dal層的方法呼叫):

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Web;
 5 using System.Web.Mvc;
 6 using BLL;
 7 using MODEL;
 8 
 9 namespace WT01.Controllers
10 {
11     public class HomeController : Controller
12     {
13         UserInfoBLL bll = new UserInfoBLL();
14 
15         //登錄頁面
16         public ActionResult Login()
17         {
18             return View();
19         }
20         //顯示頁面
21         public ActionResult Index()
22         {
23             return View();
24         }
25         //購物車頁面
26         public ActionResult MyShoppingCar()
27         {
28             return View();
29         }
30 
31         //登錄驗證
32         [HttpPost]
33         public int LoginValidate(string userid,string pwd)
34         {
35             HttpContext.Session["userid"] = userid;
36             return bll.Login(userid, pwd);
37         }
38 
39         //收藏
40         [HttpPost]
41         public int Favorite(string pnos)
42         {
43             string userid= HttpContext.Session["userid"].ToString();
44             return  new MyFavoriteBLL().Favorite(userid, pnos);
45         }
46 
47         //加入購物車
48         [HttpPost]
49         public int AddMyShoppingCar(string pnos)
50         {
51             string userid = HttpContext.Session["userid"].ToString();
52             return new MyShoppingCarBLL().AddMyShoppingCar(userid, pnos);
53         }
54 
55 
56         //獲取產品的List
57         [HttpGet]
58         public JsonResult GetList(string pname)
59         {
60             ProductBLL productBLL = new ProductBLL();
61             return Json(productBLL.GetList(pname),JsonRequestBehavior.AllowGet);
62         }
63 
64 
65         //獲取我的購物車串列資訊List
66         [HttpGet]
67         public JsonResult GetMyShoppingCarList()
68         {
69             MyShoppingCarBLL myShoppingCar = new MyShoppingCarBLL();
70             string userid = HttpContext.Session["userid"].ToString();          
71             return Json(myShoppingCar.GetList(userid), JsonRequestBehavior.AllowGet);
72         }
73 
74         //批量洗掉購物車
75         [HttpPost]
76         public int DelMyShoppingCar(string ids)
77         {
78             return new MyShoppingCarBLL().DelMyShoppingCars(ids);
79         }
80 
81         //加減1
82         [HttpPost]
83         public int MyShoppingCarsUpDown(string id, string sType)
84         {
85             return new MyShoppingCarBLL().MyShoppingCarsUpDown(id, sType);
86         }
87 
88     }
89 }
HomeController

登錄視圖中的代碼如下:

 1 @{
 2     ViewBag.Title = "Login";
 3    
 4 }
 5 <h2>Login</h2>
 6 <script src=https://www.cnblogs.com/bwxw/p/"~/Scripts/jquery-3.3.1.min.js"></script>
 7 <script>
 8 
 9     //驗證登錄
10     function LoginCheck() {
11         var userid = $("#txtAmount").val();
12         var pwd = $("#txtPwd").val();
13 
14         if (userid == "") {
15             alert("賬號不能為空!");
16             return;
17         }
18         if (pwd == "") {
19             alert("賬號不能為空!");
20             return;
21         }
22 
23 
24         $.ajax({
25             url: '/Home/LoginValidate',
26             type: 'post',
27             dataType: 'json',
28             data: { userid: userid, pwd: pwd },
29             success: function (data) {
30                 if (data > 0) {
31                     location.href = https://www.cnblogs.com/bwxw/p/'/Home/Index';
32                 }
33                 else {
34                     alert("賬號或密碼錯誤,請重新輸入");
35                     location.href = https://www.cnblogs.com/bwxw/p/'/Home/Login';
36                 }
37             }
38         })
39     }
40 
41 </script>
42 <table border="1">
43     <tr>
44         <td>賬號:</td>
45         <td><input type="text" id="txtAmount" /></td>
46     </tr>
47     <tr>
48         <td>密碼:</td>
49         <td><input type="password" id="txtPwd" /></td>
50     </tr>
51     <tr>
52         <td colspan="2">
53             <input value=https://www.cnblogs.com/bwxw/p/"登錄" type="button" id="btnLogin" onclick="LoginCheck()"  />
54         </td>
55     </tr>
56 </table>
Login.cshtml

商品顯示的視圖代碼如下:

 1 @{
 2     ViewBag.Title = "Home Page";
 3     Layout = null;
 4 }
 5 <script src=https://www.cnblogs.com/bwxw/p/"~/Scripts/jquery-3.3.1.min.js"></script>
 6 
 7 <script>
 8 
 9     //檔案就緒函式
10     $(function () {
11         QueryList();
12     })
13 
14     //收藏
15     function MyFavorite() {
16         var arr = document.getElementsByName("xselect");
17         var str = "";
18         for (var i = 0; i < arr.length; i++) {
19             if (arr[i].checked)
20                 str += arr[i].id + ",";
21         }
22         //alert(str);
23         $.ajax({
24             url: '/Home/Favorite',
25             type: 'post',
26             dataType: 'json',
27             data: { pnos: str },
28             success: function (data) {
29                 if (data > 0)
30                     alert("收藏成功!");
31             }
32         })
33     }
34 
35     //加入購物車
36     function MyShoppingCar() {
37         var arr = document.getElementsByName("xselect");
38         var str = "";
39         for (var i = 0; i < arr.length; i++) {
40             if (arr[i].checked)
41                 str += arr[i].id + ",";
42         }
43         //alert(str);
44         $.ajax({
45             url: '/Home/AddMyShoppingCar',
46             type: 'post',
47             dataType: 'json',
48             data: { pnos: str },
49             success: function (data) {
50                 if (data > 0)
51                     alert("加入購物車成功!");
52             }
53         })
54     }
55 
56     //轉到我的購物車
57     function ToMyShoppingCar() {
58         location.href =https://www.cnblogs.com/bwxw/p/'/Home/MyShoppingCar'
59     }
60     //查詢資訊
61     function QueryList() {
62         var content = $("#txtContent").val();
63 
64         $.ajax({
65             url: '/Home/GetList',
66             type: 'get',
67             dataType: 'json',
68             data: { pname: content },
69             success: function (data) {
70                 $("#tbProduct").empty();
71                 for (var i = 0; i < data.length; i++) {
72                     var tr = ' <tr>';
73                     tr += ' <td>';
74                     tr += '<img src="https://www.cnblogs.com/bwxw/' + data[i].ImgPath + '" />';
75                     tr += '<br>';
76                     tr += data[i].Price;
77                     tr += '<br>';
78                     tr += data[i].Pname;
79                     tr += '<br>';
80                     tr += '<input name="xselect" type="checkbox" id="' + data[i].Pno + '" />';
81                     tr += ' </td>';
82 
83                     tr += "</tr>";
84                     $("#tbProduct").append(tr);
85                 }
86             }
87         })
88     }
89 
90 </script>
91 
92 <input type="text" id="txtContent" /><input value=https://www.cnblogs.com/bwxw/p/"查詢" type="button" onclick="QueryList();" />&nbsp;<input value=https://www.cnblogs.com/bwxw/p/"收藏" type="button" onclick="MyFavorite();" />&nbsp;<input value=https://www.cnblogs.com/bwxw/p/"加入購物車" type="button" onclick="MyShoppingCar();" />&nbsp;<input value=https://www.cnblogs.com/bwxw/p/"我的購物車" type="button" onclick="ToMyShoppingCar();" />
93 <table id="tbProduct"></table>
Index.cshtml

購物車顯示的視圖代碼如下:

  1 @{
  2     ViewBag.Title = "MyShoppingCar";
  3    // Layout = null;
  4 }
  5 
  6 <h2>我的購物車</h2>
  7 <script src=https://www.cnblogs.com/bwxw/p/"~/Scripts/jquery-3.3.1.min.js"></script>
  8 <script>
  9 
 10     //檔案就緒函式
 11     $(function () {
 12         QueryList();
 13     })   
 14 
 15     //全選
 16     function CheckAll(o) {
 17         var chks = document.getElementsByName("xselect");
 18         for (var i = 0; i < chks.length; i++) {
 19             chks[i].checked = o.checked;
 20         }
 21     }
 22 
 23     //批量洗掉
 24     function BathDel() {
 25         var chks = document.getElementsByName("xselect");
 26         var ids = "";
 27         for (var i = 0; i < chks.length; i++) {
 28             if (chks[i].checked)
 29                 ids+=  chks[i].id+",";
 30         }
 31         $.ajax({
 32             url: '/Home/DelMyShoppingCar',
 33             type: 'post',
 34             dataType: 'json',
 35             data: { ids: ids },
 36             success: function (data) {
 37                 if (data > 0) {
 38                     QueryList();
 39                     alert('洗掉成功!');
 40                 }
 41             }
 42         })
 43     }
 44 
 45     //洗掉
 46     function DelBid(id) {      
 47         $.ajax({
 48             url: '/Home/DelMyShoppingCar',
 49             type: 'post',
 50             dataType: 'json',
 51             data: { ids: id },
 52             success: function (data) {
 53                 if (data > 0) {
 54                     QueryList();
 55                     alert('洗掉成功!');
 56                 }
 57             }
 58         })
 59 
 60     }
 61 
 62     //加減1
 63     function upDown(id, sType) {
 64         $.ajax({
 65             url: '/Home/MyShoppingCarsUpDown',
 66             type: 'post',
 67             dataType: 'json',
 68             data: { id: id, sType: sType},
 69             success: function (data) {
 70                 if (data > 0) {
 71                     QueryList();                  
 72                 }
 73             }
 74         })
 75 
 76     }
 77 
 78     //查詢資訊
 79     function QueryList() {
 80 
 81         $.ajax({
 82             url: '/Home/GetMyShoppingCarList',
 83             type: 'get',
 84             dataType: 'json',        
 85             success: function (data) {
 86                 $("#tbProduct").empty();
 87                 //拼接字串
 88                 for (var i = 0; i < data.length; i++) {
 89                     var tr = ' <tr>';
 90 
 91                     //商品
 92                     tr += ' <td>';
 93                     tr += '<input name="xselect" type="checkbox" id="' + data[i].Id + '" />&nbsp;';
 94                     tr += '<img src="https://www.cnblogs.com/bwxw/' + data[i].ImgPath + '" />';
 95                     tr += '<br>';
 96                     tr += data[i].Pname;
 97                     tr += ' </td>';
 98 
 99                     //單價
100                     tr += ' <td>';
101                     tr += data[i].Price;
102                     tr += ' </td>';
103 
104                     //數量
105                     tr += ' <td>';
106                     tr += '<a href="javascript:upDown(' + data[i].Id + ',\'down\')">-</a><input type="text" value="https://www.cnblogs.com/bwxw/p/' + data[i].Account + '"  style="width:20px" /><a href="javascript:upDown(' + data[i].Id + ',\'up\')">+</a>';
107                     tr += ' </td>';
108 
109                     //小計
110                     tr += ' <td>';
111                     tr += data[i].TotalMoney;
112                     tr += ' </td>';
113 
114                     //操作
115                     tr += ' <td>';
116                     tr += '<input type="button" value="https://www.cnblogs.com/bwxw/p/洗掉" onclick="DelBid(' + data[i].Id+')" />';
117                     tr += ' </td>';
118 
119                     tr += "</tr>";
120                     $("#tbProduct").append(tr);
121                 }
122             }
123         })
124     }
125 
126 </script>
127 <table border="1" width="100%">
128     <thead>
129         <tr>
130             <th>
131                 <input type="checkbox" onclick="CheckAll(this)" />全選&nbsp;商品
132             </th>
133             <th>
134                 單價
135             </th>
136             <th>
137                 數量
138             </th>
139             <th>
140                 小計
141             </th>
142             <th>
143                 操作
144             </th>
145         </tr>
146     </thead>
147     <tbody id="tbProduct">
148 
149     </tbody>
150 </table>
151 <input type="button" value=https://www.cnblogs.com/bwxw/p/"批量洗掉" onclick="BathDel()"/>
View Code

 

轉載請註明出處,本文鏈接:https://www.uj5u.com/net/1625.html

標籤:C#

上一篇:組態檔初始化例外Configuration system failed to initialize

下一篇:設計模式之橋接模式

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • WebAPI簡介

    Web體系結構: 有三個核心:資源(resource),URL(統一資源識別符號)和表示 他們的關系是這樣的:一個資源由一個URL進行標識,HTTP客戶端使用URL定位資源,表示是從資源回傳資料,媒體型別是資源回傳的資料格式。 接下來我們說下HTTP. HTTP協議的系統是一種無狀態的方式,使用請求/ ......

    uj5u.com 2020-09-09 22:07:47 more
  • asp.net core 3.1 入口:Program.cs中的Main函式

    本文分析Program.cs 中Main()函式中代碼的運行順序分析asp.net core程式的啟動,重點不是剖析原始碼,而是理清程式開始時執行的順序。到呼叫了哪些實體,哪些法方。asp.net core 3.1 的程式入口在專案Program.cs檔案里,如下。ususing System; us ......

    uj5u.com 2020-09-09 22:07:49 more
  • asp.net網站作為websocket服務端的應用該如何寫

    最近被websocket的一個問題困擾了很久,有一個需求是在web網站中搭建websocket服務。客戶端通過網頁與服務器建立連接,然后服務器根據ip給客戶端網頁發送資訊。 其實,這個需求并不難,只是剛開始對websocket的內容不太了解。上網搜索了一下,有通過asp.net core 實作的、有 ......

    uj5u.com 2020-09-09 22:08:02 more
  • ASP.NET 開源匯入匯出庫Magicodes.IE Docker中使用

    Magicodes.IE在Docker中使用 更新歷史 2019.02.13 【Nuget】版本更新到2.0.2 【匯入】修復單列匯入的Bug,單元測驗“OneColumnImporter_Test”。問題見(https://github.com/dotnetcore/Magicodes.IE/is ......

    uj5u.com 2020-09-09 22:08:05 more
  • 在webform中使用ajax

    如果你用過Asp.net webform, 說明你也算是.NET 開發的老兵了。WEBform應該是2011 2013左右,當時還用visual studio 2005、 visual studio 2008。后來基本都用的是MVC。 如果是新開發的專案,估計沒人會用webform技術。但是有些舊版 ......

    uj5u.com 2020-09-09 22:08:50 more
  • iis添加asp.net網站,訪問提示:由于擴展配置問題而無法提供您請求的

    今天在iis服務器配置asp.net網站,遇到一個問題,記錄一下: 問題:由于擴展配置問題而無法提供您請求的頁面。如果該頁面是腳本,請添加處理程式。如果應下載檔案,請添加 MIME 映射。 WindowServer2012服務器,添加角色安裝完.netframework和iis之后,運行aspx頁面 ......

    uj5u.com 2020-09-09 22:10:00 more
  • WebAPI-處理架構

    帶著問題去思考,大家好! 問題1:HTTP請求和回傳相應的HTTP回應資訊之間發生了什么? 1:首先是最底層,托管層,位于WebAPI和底層HTTP堆疊之間 2:其次是 訊息處理程式管道層,這里比如日志和快取。OWIN的參考是將訊息處理程式管道的一些功能下移到堆疊下端的OWIN中間件了。 3:控制器處理 ......

    uj5u.com 2020-09-09 22:11:13 more
  • 微信門戶開發框架-使用指導說明書

    微信門戶應用管理系統,采用基于 MVC + Bootstrap + Ajax + Enterprise Library的技術路線,界面層采用Boostrap + Metronic組合的前端框架,資料訪問層支持Oracle、SQLServer、MySQL、PostgreSQL等資料庫。框架以MVC5,... ......

    uj5u.com 2020-09-09 22:15:18 more
  • WebAPI-HTTP編程模型

    帶著問題去思考,大家好!它是什么?它包含什么?它能干什么? 訊息 HTTP編程模型的核心就是訊息抽象,表示為:HttPRequestMessage,HttpResponseMessage.用于客戶端和服務端之間交換請求和回應訊息。 HttpMethod類包含了一組靜態屬性: private stat ......

    uj5u.com 2020-09-09 22:15:23 more
  • 部署WebApi隨筆

    一、跨域 NuGet參考Microsoft.AspNet.WebApi.Cors WebApiConfig.cs中配置: // Web API 配置和服務 config.EnableCors(new EnableCorsAttribute("*", "*", "*")); 二、清除默認回傳XML格式 ......

    uj5u.com 2020-09-09 22:15:48 more
最新发布
  • C#多執行緒學習(二) 如何操縱一個執行緒

    <a href="https://www.cnblogs.com/x-zhi/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/2943582/20220801082530.png" alt="" /></...

    uj5u.com 2023-04-19 09:17:20 more
  • C#多執行緒學習(二) 如何操縱一個執行緒

    C#多執行緒學習(二) 如何操縱一個執行緒 執行緒學習第一篇:C#多執行緒學習(一) 多執行緒的相關概念 下面我們就動手來創建一個執行緒,使用Thread類創建執行緒時,只需提供執行緒入口即可。(執行緒入口使程式知道該讓這個執行緒干什么事) 在C#中,執行緒入口是通過ThreadStart代理(delegate)來提供的 ......

    uj5u.com 2023-04-19 09:16:49 more
  • 記一次 .NET某醫療器械清洗系統 卡死分析

    <a href="https://www.cnblogs.com/huangxincheng/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/214741/20200614104537.png" alt="" /&g...

    uj5u.com 2023-04-18 08:39:04 more
  • 記一次 .NET某醫療器械清洗系統 卡死分析

    一:背景 1. 講故事 前段時間協助訓練營里的一位朋友分析了一個程式卡死的問題,回過頭來看這個案例比較經典,這篇稍微整理一下供后來者少踩坑吧。 二:WinDbg 分析 1. 為什么會卡死 因為是表單程式,理所當然就是看主執行緒此時正在做什么? 可以用 ~0s ; k 看一下便知。 0:000> k # ......

    uj5u.com 2023-04-18 08:33:10 more
  • SignalR, No Connection with that ID,IIS

    <a href="https://www.cnblogs.com/smartstar/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/u36196.jpg" alt="" /></a>...

    uj5u.com 2023-03-30 17:21:52 more
  • 一次對pool的誤用導致的.net頻繁gc的診斷分析

    <a href="https://www.cnblogs.com/dotnet-diagnostic/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/3115652/20230225090434.png" alt=""...

    uj5u.com 2023-03-28 10:15:33 more
  • 一次對pool的誤用導致的.net頻繁gc的診斷分析

    <a href="https://www.cnblogs.com/dotnet-diagnostic/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/3115652/20230225090434.png" alt=""...

    uj5u.com 2023-03-28 10:13:31 more
  • C#遍歷指定檔案夾中所有檔案的3種方法

    <a href="https://www.cnblogs.com/xbhp/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/957602/20230310105611.png" alt="" /></a&...

    uj5u.com 2023-03-27 14:46:55 more
  • C#/VB.NET:如何將PDF轉為PDF/A

    <a href="https://www.cnblogs.com/Carina-baby/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/2859233/20220427162558.png" alt="" />...

    uj5u.com 2023-03-27 14:46:35 more
  • 武裝你的WEBAPI-OData聚合查詢

    <a href="https://www.cnblogs.com/podolski/" target="_blank"><img width="48" height="48" class="pfs" src="https://pic.cnblogs.com/face/616093/20140323000327.png" alt="" /><...

    uj5u.com 2023-03-27 14:46:16 more