アトムペイメントゲートウェイをMVCプロジェクトに統合しようとしています。CORSを有効にした後でも、この厄介なエラーが発生しています。そのため、問題の原因はおそらくリターンURLだと思いました。だから私は本当の原因を見つけるために簡単なリダイレクトを書きましたが、return Redirect("https://google.com");
それでも同じエラーが発生します。私は何が間違っているのですか?
public ActionResult TransferFund()
{
return Redirect("https://google.com");
}
Failed to load https://google.com/: Response to preflight request doesn't pass
access control check: No 'Access-Control-Allow-Origin' header is present on the requested
resource. Origin 'http://localhost:25850' is therefore not allowed
access. The response had HTTP status code 405.
私は続いているこのをリダイレクトします
編集
<script type="text/javascript">
$(document).ready(function () {
$('#btnatom').on('click', function () {
$.ajax({
type: 'POST',
url: "/AtomPayment/TransferFund",
data: {},
dataType: "text",
success: function (resultData) { alert("Save Complete") }
});
});
});
</script>
[HttpPost]
public ActionResult TransferFund()
{
return new RedirectResult("http://google.com");
string strURL, strClientCode, strClientCodeEncoded;
....
}
'POST'メソッドのため、 'TransferFund'メソッドでリダイレクトを行うことができませんでした。jqueryからそれを行います。ここで修正されたコード:
<script type="text/javascript">
$(document).ready(function () {
$('#btnatom').on('click', function () {
$.ajax({
type: 'POST',
url: "/AtomPayment/TransferFund",
data: {},
dataType: "text",
success: function (resultData) {
if(resultData == "Ok"){
alert("Save Complete");
window.location = "https://google.com/"
}
}
});
});
});
</script>
[HttpPost]
public ActionResult TransferFund()
{
//do some transfer work
return Content("Ok");
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加