当前位置: 首页 > news >正文

网站建设常见问题解决方案网页布局技术有哪些

网站建设常见问题解决方案,网页布局技术有哪些,知名的设计公司网站,江西省城市建设档案馆网站基于 Controller 的 Web API ASP.NET Wep API 的请求架构 客户端发送Http请求#xff0c;Contoller响应请求#xff0c;并从数据库读取数据#xff0c;序列化数据#xff0c;然后通过 Http Response返回序列化的数据。 ControllerBase 类 Web API 的所有controllers 一般…基于 Controller 的 Web API ASP.NET Wep API 的请求架构 客户端发送Http请求Contoller响应请求并从数据库读取数据序列化数据然后通过 Http Response返回序列化的数据。 ControllerBase 类 Web API 的所有controllers 一般继承于 ControllerBase 类而不是Controller 类。 因为 Controller 类也继承自ControllerBase 类但是支持views而API一般不需要这个功能。 ControllerBase 提供了很多处理Http Request 和 Response方法比如返回201结果的CreatedAtAction表示成功创建资源 [HttpPost] [ProducesResponseType(StatusCodes.Status201Created)] [ProducesResponseType(StatusCodes.Status400BadRequest)] public ActionResultPet Create(Pet pet) {pet.Id _petsInMemoryStore.Any() ? _petsInMemoryStore.Max(p p.Id) 1 : 1;_petsInMemoryStore.Add(pet);return CreatedAtAction(nameof(GetById), new { id pet.Id }, pet); }其他一些主要方法 Ok()返回空的 http code 200File()返回文件和 http code 200或者返回部分文件和 http code 206或者不支持的Range和http code 416PhysicalFile()返回文件和 http code 200或者返回部分文件和 http code 206或者不支持的Range和http code 416CreatedAtAction()返回 http code 201AcceptedAtAction()返回 http code 202NoContent()返回 http code 204Content()返回具体结果plain-text 格式RedirectToActionPermanent()返回 http code 301RedirectToPagePermanent()返回 http code 301RedirectToPage()返回 http code 302RedirectToRoute()返回 http code 302RedirectToAction()返回 http code 302RedirectToActionPreserveMethod()返回 http code 307RedirectToPagePreserveMethod()返回 http code 307RedirectToActionPermanentPreserveMethod()返回 http code 308RedirectToPagePermanentPreserveMethod()返回 http code 308BadRequest()返回 http code 400Problem()返回 http code 400ValidationProblem()返回 http code 400Unauthorized()返回 http code 401Challenge()返回 http code 401 或 403Forbid() 返回 http code 403NotFound()返回 http code 404Conflict() 返回 http code 409UnprocessableEntity()返回 http code 422SignIn()SignOut()StatusCode(Int32) 重要的属性 ControllerContextHttpContext获取当前action的HttpContextUrlIUrlHelper对象Request获取当前action的HttpRequestResponse获取当前action的HttpResponseRouteData获取当前action的RouteDataUser获取当前action关联的User的ClaimsPrincipal 重要的Attributes 标识 Action的功能包括 [ApiController]表示这个Action为HTTP API responses服务。包括 必须要指定 [Route(“[controller]”)]自动验证model自动bind包括[FromBody]等推断 multipart/form-data 的类型 [Area]指定Route[Bind]Route指定Route[Consumes]指定action 接收的数据类型比如 [Consumes(“application/xml”)] [Consumes(“application/json”)][Consumes(“application/x-www-form-urlencoded”)][Produces]指定action 返回的数据类型[HttpGet][HttpDelete][HttpPost][HttpPut][HttpPatch][HttpOptions][HttpHead][NonAction]表示不是Action方法[NonController]表示不是NonController方法[FromBody]标识参数或属性可以绑定Body比如 public IActionResult Action3([FromBody] Product product, [FromBody] Order order) [FromHeader][FromForm] 格式化Action 的返回结果 Action 不一定要返回某个特定类型ASP.NET Core 支持任何对象类型。 Actions 可以忽略 HttpRequest的Header的Accept返回自己想要的类型。 如果返回结果类型不是IActionResult那么会被序列化。 ControllerBase.Ok 默认返回Json类型。 Http Reponse 的 content-type: application/json; charsetutf-8. [HttpGet] public IActionResult Get() Ok(todoItemStore.GetList());而下面这个Content-Type是text/plain。 [HttpGet(Version)] public ContentResult GetVersion() Content(v1.0.0);协商结果类型 当HttpRequest 指定了Header的Accept而 Action返回的类型是JSON时会发生结果协商。 ASP.NET Core 默认支持的结果类型 application/jsontext/jsontext/plain 当Header的Accept中指定了一个类型是Action支持的类型时则返回这个类型。如果Action不支持指定的类型且设置了MvcOptions.ReturnHttpNotAcceptable为true则返回406。用Action中第一个formatter 返回结果。当Header的Accept中没有指定类型时用Action中第一个formatter 返回结果。当Header的Accept中包含/时会被忽略由Action决定。当请求来自于浏览器时Accept 会被忽略由Action决定默认返回JSON。当请求来自于浏览器时Accept 会被忽略如果Host设置了RespectBrowserAcceptHeader为true则使用浏览器的header。 如果 Action返回的结果是复杂类型时.NET 会创建一个 ObjectResult封装结果然后序列化成协商的结果类型。比如 [HttpGet({id:long})] public TodoItem? GetById(long id) _todoItemStore.GetById(id);设置成XML结果类型 var builder WebApplication.CreateBuilder(args);builder.Services.AddControllers().AddXmlSerializerFormatters();设置成使用json.net的结果类型 默认的JSON格式是基于System.Text.Json的。 var builder WebApplication.CreateBuilder(args);builder.Services.AddControllers().AddNewtonsoftJson();
http://wiki.neutronadmin.com/news/425634/

相关文章:

  • 龙岗企业网站建设哈尔滨专业官网建站企业
  • 做网站合同模板做网站手机版和电脑版怎么区分
  • 网站主办单位负责人珠江新城越秀金融大厦
  • 惠州做棋牌网站建设哪家技术好自动翻译wordpress
  • 制作复杂的企业网站首页全国建设部网站证书查询
  • 网站备案快速如何能查到百度搜索排名
  • 网站视频弹窗广告代码吉首做网站
  • 国外经典手机网站设计国际室内设计公司排名
  • 湖北省和建设厅网站郑州网站服务公司
  • 网易工作做网站工资奖金高吗html网站开发实战教程
  • 网站打不开dns修改吗企业手机网站案例
  • 建筑模型设计网站建设wordpress 代码 工具
  • 山东省城乡建设部网站首页南昌网站制作方案定制
  • 石嘴山网站seo谷歌商店下载
  • 西部数码 成品网站想招聘员工去哪个网站
  • vs2015可以做网站么石家庄网站建设今天改网名
  • 广东网站设计工具wordpress postid
  • 做网站的股哥装修广告做哪个网站最好看
  • 建一个网站是不是要开公司株洲做网站
  • 有没有便宜的网站制作seo站群干什么的
  • 六盘水网站建设58同城鞍山招聘信息
  • 网站建设书籍论文页面设计包括什么
  • app与移动网站开发考试资料dedecms网站上传服务器不是空间
  • 中国营销型网站有哪些天蝎网站建设公司
  • 大同网站设计网站域名申请流程
  • 有了网站源代码网站建设视频讲解
  • 陕西专业网站建设公司免费app软件
  • 2003服务器怎么挂网站怎么注册中视频账号
  • 深圳宝安网站推广软件开发公司属于什么企业类型
  • 深圳设计网站推荐中企动力手机邮箱