简体   繁体   中英

WebApi controller not found in ASP.NET MVC

I'm writing a asp.net web service which contains a web controller. today I add a new webapi controller to my project, when I send a request to oldest controller everything is ok and I get correct response. but when I send a request to new one, my browser(MS Edge) returns this error:

HTTP404: NOT FOUND - The server has not found anything matching the requested URI (Uniform Resource Identifier). (XHR): POST - http://localhost:3982/api/ViewTemplates

It returns error while both of controllers are in a same namespace and place together in a folder.

I try defining my new request path

http://localhost:3982/api/ViewTemplates

manually in WebApiConfig.cs but it doesn't work so I change this class to it's default configuration.

can you help me?

thanks

您是否尝试过删除bin目录,清理解决方案并重建。

HTTP404: NOT FOUND - The server has not found anything matching the requested URI (Uniform Resource Identifier). (XHR): POST - http://localhost:3982/api/ViewTemplates

This Error means the url you are requesting on this link http://localhost:3982/api/ViewTemplates not exists. Check folder path or project path directory.

Second thing is most of filenames in asp project has .aspx at the end like this http://localhost:3982/api/ViewTemplates.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM