MVC的视图中,ajax的url应该如何写

我在Video控制器的Details视图中,写了如下js代码:
$.ajax({
type: "post",
url: "Comment/CreateComment",
data: { video_id: video_id, opinion: opinion }, });
本意是希望通过按钮事件调用Create Comment方法,但是调试结果显示,ajax的url地址为Video/Details/Comment/Create Comment

给请求的url前面加一个/,这样才能请求到根,不然就是当前路径下的请求

CreateComment函数上面加个[Route("/Comment/CreateComment")]。这个地址你要做统一。

url: "../Comment/CreateComment",