上一页 1 ··· 98 99 100 101 102 103 104 105 106 ··· 164 下一页
摘要: Creating a REST service using ASP.NET Web APIByAfter2050,13 Sep 20124.33(3 votes)IntroductionA service that is created based upon the architecture ofRESTis called as REST service. Although REST looks more inclined to web and HTTP its principles can be applied to other distributed communication syste 阅读全文
posted @ 2012-12-15 13:03 火腿骑士 阅读(386) 评论(0) 推荐(0)
摘要: public Task Get(int id){ var task = _taskRepository.Get(id); if (task == null) { throw new HttpResponseException(new HttpResponseMessage { StatusCode = HttpStatusCode.NotFound, Content = new StringContent("Task not found") }); } return task;}public Task Put(Task task){ try { task = _taskRe 阅读全文
posted @ 2012-12-15 12:55 火腿骑士 阅读(231) 评论(0) 推荐(0)
摘要: https://packages.nuget.org/packages 阅读全文
posted @ 2012-12-14 15:46 火腿骑士 阅读(159) 评论(0) 推荐(0)
摘要: ASP.NET MVC3使用PagedList实现分页导航九月 3, 2012分页导航功能在Web应用中再常见不过了,本文介绍了近期项目开发过程中如何利用PagedList库实现数据条目的分页导航功能,项目其实很简单,就是实现一个简单的内容管理系统,具备增删改查的功能,采用了ASP.NET MVC3技术。使用NuGet包管理器,具体做法:右键项目的References => Manage NuGet Packages => 搜索PagedList安装。这里需要下载两个DLL,分别是PagedList.dll和PagedList.Mvc.dll,其中PagedList适用MVC2框架 阅读全文
posted @ 2012-12-14 15:36 火腿骑士 阅读(321) 评论(0) 推荐(0)
摘要: if(Request.Content.IsMimeMultipartContent()){ var streamProvider =newMultipartMemoryStreamProvider(); var task =Request.Content.ReadAsMultipartAsync(streamProvider).ContinueWith(t =>//上传多个文件 { foreach(var item in streamProvider.Contents) { //do something }});public class UploadFileController : Ap 阅读全文
posted @ 2012-12-14 14:25 火腿骑士 阅读(444) 评论(0) 推荐(0)
摘要: 关于MVC4.0 WebAPI上传图片重命名以及图文结合MVC4.0 WebAPI上传后的图片默认以字符串bodypart结合Guid来命名,且没有文件后缀,为解决上传图片重命名以及图文结合发布的问题,在实体对象的处理上,可将图片属性定义为byte[]对象,至于图片的重命名,通过重写继承MultipartFormDataStreamProvider类来解决!参照API的官方文档,上传文件代码大致如下:public Task<HttpResponseMessage> PostFile() { HttpRequestMessage request = this.... 阅读全文
posted @ 2012-12-14 14:22 火腿骑士 阅读(467) 评论(0) 推荐(0)
摘要: 介绍 asp.net mvc 之 asp.net mvc 4.0 新特性之 Web API自宿主 web api宿主到 iis,通过 WebForm 提供 web api 服务通过 Web API 上传文件.net 4.5 带来的更方便的异步操作示例 1、自宿主 Web API 的 demo WebApiSelfHost/Program.cs/* * 自宿主 web api 的 demo * * 测试地址:http://localhost:123/api/hello */using System;using System.Collections.Generic;using System.Li. 阅读全文
posted @ 2012-12-14 14:19 火腿骑士 阅读(247) 评论(0) 推荐(0)
摘要: 作者:webabcd 介绍 asp.net mvc 之 asp.net mvc 4.0 新特性之 Web API开发一个 CRUD 的 Demo,服务端用 Web API,并使其支持 jsonp 协议,客户端用 jQuery示例 1、自定义一个 JsonMediaTypeFormatter,以支持 jsonp 协议 MyJsonFormatter.cs/* * 自定义一个 JsonMediaTypeFormatter,以支持 jsonp 协议 */using System;using System.Collections.Generic;using System.IO;using System 阅读全文
posted @ 2012-12-14 14:18 火腿骑士 阅读(189) 评论(0) 推荐(0)
摘要: using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;using System.Web.Mvc.Ajax;using System.IO;namespace MVC.Controllers{ /**/ /// <summary> /// Controller 类必须以字符串 "Controller" 做类名称的结尾,字符串 Controller 之前的字符串为 Controller 的名称,类中的方法名为 Acti 阅读全文
posted @ 2012-12-14 12:54 火腿骑士 阅读(134) 评论(0) 推荐(0)
摘要: 在 Controller 中我们可以使用 FileResult 向客户端发送文件。FileResultFileResult 是一个抽象类,继承自 ActionResult。在 System.Web.Mvc.dll 中,它有如上三个子类,分别以不同的方式向客户端发送文件。在实际使用中我们通常不需要直接实例化一个 FileResult 的子类,因为 Controller 类已经提供了六个 File 方法来简化我们的操作:protected internal FilePathResult File(string fileName, string contentType);protected inte 阅读全文
posted @ 2012-12-14 12:49 火腿骑士 阅读(180) 评论(0) 推荐(0)
上一页 1 ··· 98 99 100 101 102 103 104 105 106 ··· 164 下一页