很简单,创建area后,添加一下代码到AreaRegistration中即可

context.Routes.MapHttpRoute(
name: "api_default",
routeTemplate: "{area}/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);

  

注意:

1. name不要重名

2. 尽量将代码优先放在靠前的顺序

WebAPI中Area的使用的更多相关文章

  1. WebAPI增加Area以支持无限层级同名Controller

    原文:WebAPI增加Area以支持无限层级同名Controller 微软的WebAPI默认实现逻辑 默认实现中不支持同名Controller,否则在访问时会报HttpError,在网上找到了各种路由 ...

  2. Autofac - MVC/WebApi中的应用

    Autofac前面写了那么多篇, 其实就是为了今天这一篇, Autofac在MVC和WebApi中的应用. 一.目录结构 先看一下我的目录结构吧, 搭了个非常简单的架构, IOC(web), IBLL ...

  3. WebAPI中无法获取Session对象的解决办法

    在MVC的WebApi中默认是没有开启Session会话支持的.需要在Global中重写Init方法来指定会话需要支持的类型 public override void Init() { PostAut ...

  4. webapi 中的本地登录

    WebApi 身份验证方式 asp.net WebApi 中有三种身份验证方式 个人用户账户.用户可以在网站注册,也可以使用 google, facebook 等外部服务登录. 工作和学校账户.使用活 ...

  5. webapi 中使用 protobuf

    相比json来说,好处是速度更快,带宽占用更小.其效果大致等于json+Gzip. 在webapi中使用protobuf的方法为: 引用nuget包 Install-Package protobuf- ...

  6. 【AspNetCore】【WebApi】扩展Webapi中的RouteConstraint中,让DateTime类型,支持时间格式化(DateTimeFormat)

    扩展Webapi中的RouteConstraint中,让DateTime类型,支持时间格式化(DateTimeFormat) 一.背景 大家在使用WebApi时,会用到DateTime为参数,类似于这 ...

  7. 在asp.net WebAPI 中 使用Forms认证和ModelValidata(模型验证)

    一.Forms认证 1.在webapi项目中启用Forms认证 Why:为什么要在WebAPI中使用Forms认证?因为其它项目使用的是Forms认证. What:什么是Forms认证?它在WebAP ...

  8. 在WebAPI中自动创建Controller

    在MIS系统中,大部分的操作都是基本的CRUD,并且这样的Controller非常多. 为了复用代码,我们常常写一个泛型的基类. public class EntityController<T& ...

  9. .net WebApi中使用swagger

    我在WebApi中使用swagger的时候发现会出现很多问题,搜索很多地方都没找到完全解决问题的方法,后面自己解决了,希望对于遇到同样问题朋友有帮助.我将先一步一步的演示项目中解决swagger遇到问 ...

随机推荐

  1. <input type=XXXXX>

    选框,提交/重置按钮等,下面一一介绍. 1,type=text  输入类型是text,这是我们见的最多也是使用最多的,比如登陆输入用户名,注册输入电话号码,电子邮件,家庭住址等等.当然这也是Input ...

  2. UVa 12403 - Save Setu

    题目:有两种操作:1.当前数值添加.2.输出当前数值. 分析:简单题.模拟就可以. 说明:A+B. #include <iostream> #include <cstdlib> ...

  3. buildroot的使用简介【转】

    本文转载自:http://blog.csdn.net/flfihpv259/article/details/51996204 buildroot简介 1 Buildroot at a glance 2 ...

  4. get the page name from url

    https://stackoverflow.com/questions/1874532/better-way-to-get-page-name The way I interpret the ques ...

  5. git unstage

    https://stackoverflow.com/questions/6919121/why-are-there-2-ways-to-unstage-a-file-in-git git rm --c ...

  6. Linux设备模型 (3)

    在上文中,我们介绍到如何使用default attribute.Default attribute使用很方便,但不够灵活.比如上篇文章在Kobject一节中提到的那个例子,name和val这两个att ...

  7. VMware虚拟机安装WinXP出现错误output error file to the following location A:\GHOSTERR.TXT

    我们安装Ghost版WinXP系统的时候,可能会出现一个如下图这样的错误:output error file to the following location A:\GHOSTERR.TXT. 出现 ...

  8. 解决UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position xxx ordinal not in range(128)

    Python在安装时,默认的编码是ascii,当程序中出现非ascii编码时,python的处理常常会报这样的错UnicodeDecodeError: 'ascii' codec can't deco ...

  9. 杂项:IntelliJ IDEA

    ylbtech-杂项:IntelliJ IDEA 1.返回顶部   2.返回顶部   3.返回顶部   4.返回顶部   5.返回顶部     6.返回顶部   作者:ylbtech出处:http:/ ...

  10. linux上部署javaWeb项目

    将web项目打成war包,上传到Linux操作系统tomcat安装目录下的webapps下即可!