Ajax中post后台.net MVC中Controller的路径问题。

今天使用ajax的post方法,去访问mvc的controller,url的传值是 "//ProductCatalog/PostShareInfo",发现无论如何都访问不到。

我实际想要访问的地址是“http://localhost/ProductCatalog/PostShareInfo”,而真实的访问地址是,“http://ProductCatalog/PostShareInfo”,少了localhost

原因是因为,前面多了一个/,应该为"/ProductCatalog/PostShareInfo",不是"//ProductCatalog/PostShareInfo"

根据:https://blog.youkuaiyun.com/laokaizzz/article/details/22889725,中的说明

url 参数

是 UserManage/UpdateUser  时,是去访问 http://localhost/Home/UserManage/UpdateUser 

是 ~/UserManage/UpdateUser  时,是去访问 http://localhost/Home/~/UserManage/UpdateUser   不支持~ 因为不是服务器 ,是js

是 /UserManage/UpdateUser   时,是去访问 http://localhost/UserManage/UpdateUser  

最前面写 / 是表示 根目录,不加 / 表示当前目录

而如果url地址中最前是两个/,"//",会导致访问的时候,跳过了localhost,以至于无法访问到正确的controller地址。

 

转载于:https://www.cnblogs.com/tfiremeteor/p/9072833.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值