更新时间:2023-02-15 23:12:01
检查你的 RouteConfig
类在 App_Start
文件夹中。您应该看到的默认路由下面,你可以改变。
Check your your RouteConfig
class in your App_Start
folder. You should see the default route below which you can change.
routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
修改
阅读您的意见后,我觉得这个问题是不是与你的路由。我不知道你为什么会的希望的去做,但你只需要指定起始网址为您的项目。右键单击您的Web项目 - 点击属性 - 点击网络标签 - 在开始行动选择开始网址,然后输入 HTTP ://本地主机:45678 / API /产品
在框中。保存项目并再次运行。它应该在新的位置开始。
After reading your comments, I think the problem is not with your routes. I'm not sure why you would want to do it, but you just need to specify the Start URL for your project. Right click your web project - click Properties - click the Web tab - under Start Action select Start URL and enter http://localhost:45678/api/Products
in the box. Save your project and run again. It should start at the new location.