c# 【MVC】WebApi开发实例

using System;using System.Collections.Generic;using System.ComponentModel.DataAnnotations;using System.Linq;using System.Web;namespace ProductStore.Models{ //商品实体类 public class Product …… 阅读全文

c# 【MVC】WebApi返回各种类型(图片/json数据/字符串)

using System.IO;/// /// WebApi返回图片/// public HttpResponseMessage GetQrCode(){ var imgPath = @"D:\ITdosCom\Images\itdos.jpg"; //从图片中读取byte var imgByte = File.ReadAllBytes(imgPath); …… 阅读全文

c# 【MVC】WebApi通过HttpClient来调用Web Api接口

/// /// HttpClient实现Post请求(异步)/// static async void dooPost(){ string url = "http://localhost:52824/api/register"; //设置HttpClientHandler的AutomaticDecompression var handler = new HttpClientHand …… 阅读全文

c# 【MVC】WebApi设置返回Json

public static HttpResponseMessage toJson(Object obj) { String str; if (obj is String || obj is Char) { str = obj.ToString(); } …… 阅读全文

Entity Framework 之Code First自动数据迁移

using MvcShopping.Migrations;using MvcShopping.Models;using System;using System.Collections.Generic;using System.Data.Entity;using System.Linq;using System.Web;using System.Web.Http;using Syst …… 阅读全文

【MVC】MvcPager分页及边界传递数据示例

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;using MvcTest.Models;using Webdiyer.WebControls.Mvc;namespace MvcTest.Controllers{ pu …… 阅读全文