几个常用但是不经常用的Action记录
只是为了记录测试一个返回内容,不对代码做格式优化
if (id == “1”)
 {
 return new NotFoundResult(); //404
 }
 else if (id == “2”)
 {
 return new NotFoundObjectResult(new { a = “404”, b = “没有发现内容” }); //返回404+自定义内容
 }
 else if (id == “3”)
 {
 return new NoContentResult(); //无内容结果
 }
 else if (id == “4”)
 {
 return new ObjectResult(new { a = “123”, b = “没有发现内容” }); //返回Objecct 也可以使用 JsonResult
 }
 else if (id == “5”)
 {
 return new ContentResult { Content = “内容”, StatusCode = 200 }; //返回内容
 }
 else if (id == “6”) //下载附件
 {
 PhysicalFileResult f = new PhysicalFileResult(@“E:\work\codes\技术积累\临时\weixinshare\weixinshare\weixinshare\wwwroot\File\weixinimg\2edf0b9324cb44edaa7d73ea46ab0b15.jpg”
 , “application/file”);
 f.FileDownloadName = “ddd.jpg”;
 f.EnableRangeProcessing = true;
 f.LastModified = DateTimeOffset.Now;
 return f;
 }
 else if (id == “7”)
 {
 return new ForbidResult(); //403Forbid
 }
 else if (id == “8”)
 {
 return Redirect(“http://www.kalehu.com”);//跳转外连接
 }
 else return new LocalRedirectResult(“~/weixin/index.html”); //站点内跳转