WEBAPI路由 [英] WEBAPI Routing

查看:89
本文介绍了WEBAPI路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是创建webapi方法的新手。  

I'm new to creating webapi methods.  

我有一个继承自ApiController的控制器。  它有一个方法:

I have a controller that inherits from ApiController.  It has a method:

        [路线(&〜; api / stateandcountyfromapi / {apiNumber}")])
        public string StateAndCountyFromAPI(string apiNumber)

        [Route("~api/stateandcountyfromapi/{apiNumber}")]
        public string StateAndCountyFromAPI(string apiNumber)

我想我应该能够从客户端调用它as:

I figure I should be able to call it from the client such as:

api / stateandcountyfromapi /'33112244'

api/stateandcountyfromapi/'33112244'

尝试此操作时出现404错误。  我缺少的东西,但不确定是什么。

I get 404 errors when trying this.  Something I'm missing, but not sure what.

Stockton

推荐答案

这个问题似乎是关于ASP.Net的,在这种情况下,最好将它发布在
ASP.Net论坛
This question appears to be about ASP.Net, in which case it would be better to post it in the ASP.Net forums.


这篇关于WEBAPI路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆