$.post 向C#的 controller 发送请求时,碰到的问题。
Request URL:http://localhost:51988/CQA/SearchQA Request Headersview source Accept:text/plain, */*; q=0.01 Content-Type:application/x-www-form-urlencoded; charset=UTF-8 Origin:http://localhost:51988 Referer:http://localhost:51988/CQA/KeywordSearch User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 Safari/537.31 X-Requested-With:XMLHttpRequest Form Dataview sourceview URL encoded keyword:我靠 pageSize:10 pageIndex:1
这是 localhost:51988/CQA/KeywordSearch 页面,向CQA/SearchQA 发送请求的 头
Request URL:http://localhost:51988/CQA/SearchQA Request Headersview source Accept:text/plain, */*; q=0.01 Content-Type:application/x-www-form-urlencoded; charset=UTF-8 Origin:http://localhost:51988 Referer:http://localhost:51988/MembersTask/TraLabeling/54703?r=1469470069 User-Agent:Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.43 Safari/537.31 X-Requested-With:XMLHttpRequest Form Dataview sourceview URL encoded keyword:我靠 pageSize:10 pageIndex:1
这是 localhost:51988/MembersTask/TraLabeling/54703?r=1469470069 页面,向CQA/SearchQA 发送请求的 头
两个头信息除了源页面不同外,其他全部相同。
第一次 post 请求发送成功,而第二次确实失败的。
问题:使用$.post发送请求,页面是完全相同的页面,分别从两个不同的controller 打开,其中一个是和post请求相同的controller (CQA) 另外一个则是不同的 controller 打开的。结果,从不同的controller打开的页面 使用$.post 发请求发送不出去。而同一个controller 打开的页面发请求则没有问题。
然后我再 MemberTask 这个 controller 中拷贝了一个 和 CQA 中接受请求完全一样的方法。两个页面的post 都能够正常的发送请求