0
字符串我有非常简单的代码:获取REST调用没有返回,我把网址
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
namespace Calculator.Controllers
{
public class CalcController : ApiController
{
public string Get(string type)
{
return type;
}
}
}
而这正是它,当我在http://www.example.com/api/calc/test
<string xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/" i:nil="true"/>
键入当我使用http://www.example.com/api/calc/?type=test返回它返回这个:
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">test</string>
我如何做到这一点,我可以只做顶部的而不是底部的?
两两件事,我没有一个默认的,在这里添加此之后:'公共静态无效的RegisterRoutes(RouteCollection路线) { routes.MapHttpRoute(名称:“路径1”,routeTemplate:“API /计算器/ {type}“,默认值:new {controller =”Calc“} ); }' – wizage
添加此路由后它工作吗? – VJAI
不,它不工作它仍然返回此:' ' –
wizage