WebApi访问方式配置
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http; namespace RouteFirstApi
{
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API 配置和服务 // Web API 路由
config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http; namespace RouteFirstApi.Controllers
{
public class OrderController : ApiController
{ [HttpGet]
public IHttpActionResult GetAll() {
return Ok<string>("Success");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http; namespace RouteFirstApi.Controllers
{
[RoutePrefix("api/Order")]
public class OrderController : ApiController
{
[Route("")]
[HttpGet]
public IHttpActionResult GetAll() {
return Ok<string>("Success");
} [Route("{ id:int }")]
[HttpGet]
public IHttpActionResult GetById(int id) {
return Ok<string>("带id的int类型" + id);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http; namespace RouteFirstApi
{
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API 配置和服务 // Web API 路由
config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
}
WebApi访问方式配置的更多相关文章
- 网站开发进阶(一)Tomcat域名或IP地址访问方式配置方法
Tomcat域名或IP地址访问方式配置方法 1.配置www.***.com域名方式访问 在Tomcat下面配置域名(如:www.***.com)的时候,同时又不希望客户通过我们网站的IP或者域名访问到 ...
- Centos下安装FTP并进行虚拟用户访问方式配置
1. 安装认证所需包 [root@localhost]#yum install pam* [root@localhost]#yum install db4* 首先安装PAM(用于用户认证)和DB4(用 ...
- .NetCore WebApi结构及前端访问方式
.NetCore WebApi结构及前端访问方式(Ajax方式,fetch方式,axios方式) //访问的地址api/控制器名称/方法名称;action一般会省略 [Route("api/ ...
- 【PCIE-2】---PCIE配置空间及访问方式简介
对新手来说,第一步了解PCIE的相关基本概念,第二步了解PCIE配置空间,第三步深入研究PCIE设备枚举方式.本章主要总结第二步的PCIE配置空间 按照国际惯例,先提问题: 1. 什么是PCIE的配置 ...
- Beetlex服务框架之Webapi访问限制和url重写
在新版本的BeetleX.FastHttpApi中集成了IP访问策略和URL重写两个功能,通过IP访问策略可以制定服务针对不同IP的访问限制控制:而URL重写则可以制定更好的URL访问方式.以下介绍这 ...
- ADO.NET编程之美----数据访问方式(面向连接与面向无连接)
最近,在学习ADO.NET时,其中提到了数据访问方式:面向连接与面向无连接.于是,百度了一下,发现并没有很好的资料,然而,在学校图书馆中发现一本好书(<ASP.NET MVC5 网站开发之美&g ...
- java web学习总结(二十一) -------------------模拟Servlet3.0使用注解的方式配置Servlet
一.Servlet的传统配置方式 在JavaWeb开发中, 每次编写一个Servlet都需要在web.xml文件中进行配置,如下所示: 1 <servlet> 2 <servlet- ...
- 在APACHE服务器上的访问方式上去除index.php
在APACHE服务器上的访问方式上去除index.php 下面我说下 apache 下 ,如何 去掉URL 里面的 index.php 例如: 你原来的路径是: localhost/index ...
- HDFS副本机制&负载均衡&机架感知&访问方式&健壮性&删除恢复机制&HDFS缺点
副本机制 1.副本摆放策略 第一副本:放置在上传文件的DataNode上:如果是集群外提交,则随机挑选一台磁盘不太慢.CPU不太忙的节点上:第二副本:放置在于第一个副本不同的机架的节点上:第三副本:与 ...
随机推荐
- Can't load AMD 64-bit .dll on a IA 32-bit platform错误
将tomcat的bin目录下的tcnative-1.dll文件删除.就可以了.
- MySQL当月负毛利订单明细_20161027
#当月每天负毛利订单明细 SELECT c.ID,a.city AS 城市,a.username AS 用户ID,a.订单日期,a.订单号,a.销售确认额,a.成本额,a.毛利1, CASE THEN ...
- 【Lintcode】038.Search a 2D Matrix II
题目: Write an efficient algorithm that searches for a value in an m x n matrix, return the occurrence ...
- HTML Document 头
1. 比较宽松的HTML格式,样式 <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"> 如下 ...
- 浏览器,tab页显示隐藏的事件监听--页面可见性
//监听浏览器tab切换,以便在tab切换之后,页面隐藏的时候,把弹幕停止 document.addEventListener('webkitvisibilitychange', function() ...
- 向nexus远程仓库里面添加JAR
向nexus远程仓库里面添加JAR 远程仓库:http://10.1.252.21:8081/nexus/index.html admin/admin123 方法一:手动 在左侧选择:Reposito ...
- 梯度算子(普通的+Robert + sobel + Laplace)
1.水平垂直差分法: 2.Robert 算子梯度 3.sobel算子 4.拉普拉斯算子
- grep的用法(CentOS7)及有关正则表达式的使用
环境准备:alias grep="grep --color" 1.grep以整行为单位进行处理,行中有的匹配显示出来 Last中取出符合root的行:grep '查找字符串' l ...
- Open Live Writer测试
************************我是可爱的分界线***************************
- Weblogic学习
1.WebLogic目录介绍: coherence:集群组件 modules:第三方的模块包 user_projects:存放域的文件夹(必须要创建域) utils 工具包 uninstall ...