国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

點字符“” 在MVC Web API 2中進行請求,例如api / people / STAFF.45287

瀏覽:134日期:2024-05-11 16:58:42
(adsbygoogle = window.adsbygoogle || []).push({}); 如何解決點字符“” 在MVC Web API 2中進行請求,例如api / people / STAFF.45287?

在web.config文件中進行以下設置應該可以解決您的問題:

<configuration> <system.webServer><modules runAllManagedModulesForAllRequests='true' />解決方法

我嘗試使用的URL是以下格式的URL:http ://somedomain.com/api/people/staff.33311(就像LAST.FM這樣的站點允許其RESTFul和WebPageurl中的各種符號一樣,例如“http://www.last.fm/artist/psy’aviah”是LAST.FM的有效網址)。

在以下情況下有效:-http://somedomain.com/api/people/-返回所有人-http://somedomain.com/api/people/staff33311-也可以使用,但不是我所需要的我希望網址接受一個“點”之后的m,例如下面的示例-http://somedomain.com/api/people/staff.33311-但這給了我一個

HTTP Error 404.0 - Not FoundThe resource you are looking for has been removed,had its name changed,or is temporarily unavailable.

我已經設置了以下內容:

控制器“ PeopleController”

public IEnumerable<Person> GetAllPeople()

{ return _people;}

public IHttpActionResult GetPerson(string id){ var person = _people.FirstOrDefault(p => p.Id.ToLower().Equals(id.ToLower())); if (person == null)return NotFound();

return Ok(person);

}

WebApiConfig.cs

public static void Register(HttpConfiguration config)

{ // Web API configuration and services

// Web API routesconfig.MapHttpAttributeRoutes();config.Routes.MapHttpRoute( name: 'DefaultApi',routeTemplate: 'api/{controller}/{id}',defaults: new { id = RouteParameter.Optional });

}

我已經嘗試按照該博客文章的所有提示進行操作,網址為http://www.hanselman.com/blog/ExperimentsInWackinessAllowingPercentsAnglebracketsAndOtherNaughtyThingsInTheASPNETIISRequestURL.aspx,但仍然無法正常工作。更好,更安全的方式。

我們的ID在內部是這樣的,因此我們將不得不找到一種解決方案,以一種或另一種方式來匹配點,最好采用“”樣式。但如果需要的話,我愿意接受有關網址的替代建議…

標簽: web
主站蜘蛛池模板: 会昌县| 黄平县| 宜阳县| 海安县| 河东区| 全南县| 克山县| 闻喜县| 涞水县| 屯昌县| 原平市| 浠水县| 西安市| 浪卡子县| 沅江市| 分宜县| 麦盖提县| 太仓市| 万全县| 宁武县| 仁怀市| 海口市| 惠水县| 滁州市| 绵竹市| 内黄县| 乌海市| 江源县| 凤城市| 鲁甸县| 余江县| 闵行区| 武安市| 聂荣县| 金昌市| 永善县| 舒城县| 靖江市| 花垣县| 友谊县| 宣武区|