是否可以从Myown MVC4应用程序向其他MVC4互联网应用程序提供服务 [英] Is it possible to provide services to other MVC4 internet application from Myown MVC4 application
问题描述
是否可以从Myown MVC4应用程序向其他MVC4互联网应用程序提供一些服务。
Is it possible to provide some services to other MVC4 internet application from Myown MVC4 application.
推荐答案
If main application provides OData then we can use it anywhere in else application
The Open Data Protocol (OData) is a data access protocol for the web. OData provides a uniform way to query and manipulate data sets through CRUD operations (create, read, update, and delete).
你的MVC行动方法应该是这样的
[可查询(ResultLimit = 10)]
public IQueryable< service>得到()
{
返回新服务[]
{
新服务{Id = 1,描述=这是我的服务1. },
新服务{Id = 2,描述=这是我的服务2.},
新服务{Id = 3,Description =这是我的服务3.}
} .AsQueryable();
}
现在您可以请求这样的'请求/ api / service?
Your MVC Action method should be like this
[Queryable(ResultLimit = 10)]
public IQueryable<service> Get()
{
return new Service[]
{
new Service { Id = 1, Description = "This is my service 1." },
new Service {Id = 2, Description = "This is my service 2."},
new Service {Id = 3, Description = "This is my service 3."}
}.AsQueryable();
}
Now you can request it like this ‘request to /api/service?
top = 2'
和你会得到像这样的json回复
{{Id:1,Description:这是我的服务1.},{Id :2,说明:这是我的服务2。}}
top=2’
And you will get json response like this
{ { "Id": "1", "Description": "This is my service 1."}, { "Id": "2", "Description": "This is my service 2."}}
这篇关于是否可以从Myown MVC4应用程序向其他MVC4互联网应用程序提供服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!