.Net Web Api
Leckun
这个作者很懒,什么都没留下…
展开
-
WebAPI (MVC)Windows Server 2008 IIS部署404错误的解决办法
只需要在web.config里加上这一句,原因未知原创 2016-05-31 19:46:53 · 7110 阅读 · 0 评论 -
WebAPI序列化后的时间中含有“T”的解决方法
web api中序列化后的时间中含有“T”的解决方法在web api中,系统会自动将返回的对象序列化为json数据,但是如果对象中含有时间的话,序列化后的时间中会含有“T”字符,如下:[csharp] view plain copy public object getJson() { var rst = new原创 2016-05-04 13:43:57 · 6507 阅读 · 0 评论 -
陨石坑之webapi使用filter
首先为什么说这是一个坑,是因为我们在webapi中使用filter的时候也许会先百度一下,好吧,挖坑的来了,我看了好几篇文章写的是使用System.Web.Mvc.Filters.ActionFilterAttribute。然后开始痛苦的调试,发现这个过滤器永远调不进来(windows azure mobile services除外)。then.... 还是Google吧 !转载 2017-03-28 14:11:29 · 1881 阅读 · 0 评论 -
System.Threading.Timer定时器停止运行(失效)问题解决方法
一、现象在一个WebAPI项目中某个方法Tools()里使用定时器var timer = new System.Threading.Timer((unused) => { Console.WriteLine("1"); }, null, 0, 1000);//1秒一次部署到IIS后,发现定时器老是失效,没有原创 2017-03-29 14:53:03 · 17887 阅读 · 0 评论 -
获得WebAPI原始POST请求BODY的JSON内容
在controller的action里写如下代码:string content = Request.Content.ReadAsStringAsync().Result;但是这段代码获取的content却是空的,搞了半天没明白,后来在一个国外的论坛找到了原因。原因是这样的,当你的Action参数存在[FromBody]等读取内容的方法时,会被[FromBody]“吃掉”。说得有些生动,原创 2017-09-21 09:17:12 · 19365 阅读 · 0 评论 -
WebAPI HelpPage出现Failed to generate the sample for media type 'application/x-www-form-urlencoded'. 错
WebApi参数页面的示例里,出现Failed to generate the sample for media type 'application/x-www-form-urlencoded'. Cannot use formatter 'JQueryMvcFormUrlEncodedFormatter' to write type 'Vehicle'.调试查了一下原因,是因为Web原创 2017-10-16 10:15:51 · 2663 阅读 · 0 评论 -
js和css文件自动在后缀处添加版本号(.NET)
基本用法为防止浏览器缓存,一般会在js和css文件后添加版本号,但每次手工改将会很麻烦,因此可以考虑自行将文件修改时间作为版本号,并且自动附加到页面上。先写一个获取文件名的公共方法:public string GetFileTimeStampString(string filePath){ FileInfo fi = new FileInfo(Server.MapPath(file原创 2017-11-29 14:20:19 · 9805 阅读 · 2 评论 -
【整理】fiddler不能监听 localhost和 127.0.0.1的问题
localhost/127.0.0.1的请求不会通过任何代理发送,fiddler也就无法截获。解决方案有5种方案1,用 http://localhost. (locahost紧跟一个点号)方案2,用 http://127.0.0.1. (127.0.0.1紧跟一个点号)方案3,用 http://machinename (机器名)方案4,将localhost、127.0.0.1全部替换为h...转载 2018-10-25 16:31:03 · 5892 阅读 · 1 评论
分享