[{"data":1,"prerenderedAt":96},["ShallowReactive",2],{"/2025/11/10-asp.net-web-api-404-the-resource-cannot-be-found":3},{"id":4,"title":5,"body":6,"date":87,"description":80,"extension":88,"meta":89,"navigation":90,"path":91,"robots":92,"seo":93,"stem":94,"__hash__":95},"posts/2025/11/10 ASP.NET-Web-API-404-The-Resource-Cannot-Be-Found.md","10 ASPNET Web API 404 The Resource Cannot Be Found",{"type":7,"value":8,"toc":84},"minimark",[9,18,25,28,31,33,36,55,57,67,81],[10,11,13],"post-title",{":date":12},"date",[14,15,17],"h1",{"id":16},"aspnet-web-api-404-the-resource-cannot-be-found","ASP.NET Web API 404 The Resource Cannot Be Found",[19,20,21],"notes",{},[22,23,24],"p",{},"This is a repost from my old blog. First posted in 1/20/2020.",[26,27],"br",{},[22,29,30],{},"I have an old ASP.NET Web API 2 which I would like to update with OWIN. As usual, it didn't go smoothly.",[26,32],{},[22,34,35],{},"After updating to OWIN, it somehow threw a 404 error. I spent hours trying various things as stated below but none works.",[37,38,39,43,46,49,52],"ul",{},[40,41,42],"li",{},"Verified the order of route registration",[40,44,45],{},"Attempted to use Route attributes",[40,47,48],{},"Applied runAllManagedModulesForAllRequests=\"true\" on modules tag in web.config",[40,50,51],{},"Made sure spelling, Nuget packages and imports are correct",[40,53,54],{},"Checked with a brand new Web API project to make sure code are correct",[26,56],{},[22,58,59,60,66],{},"At the end, I remembered that I accidentally hit \"Create Virtual Directory\" when the Project Url field was set to \"",[61,62,65],"a",{"rel":63},[64],"nofollow","http://localhost:xxxxx/api","\" and using IIS Express. I suspect the virtual directory was the issue. After few online searches, I found the virtual directory was set in:",[68,69,70],"code-block",{},[71,72,77],"pre",{"className":73,"code":75,"language":76},[74],"language-text","\u003Csolution folder>/.vs/config/applicationhost.config. \n","text",[78,79,75],"code",{"__ignoreMap":80},"",[22,82,83],{},"Removing the virtual directory solves my 404 issue.",{"title":80,"searchDepth":85,"depth":85,"links":86},2,[],"2025-11-10T00:00:00.000Z","md",{},true,"/2025/11/10-asp.net-web-api-404-the-resource-cannot-be-found",null,{"title":5,"description":80},"2025/11/10 ASP.NET-Web-API-404-The-Resource-Cannot-Be-Found","9IUYVQ_Zl-eCCnhZXFBK773z56su6Qkd1R6FSvuqm6w",1785167452584]