窗口未重定向到从 Json 返回传递的正确 URL

发布于 2024-10-31 18:09:14 字数 1174 浏览 0 评论 0原文

function GetOpenUrl(transactionId, legacyIndication)
    {
        var json = {
            id : transactionId,
            legacyIndication : legacyIndication
        };
         $.ajax({
            type: "POST",
            url: "<%= Url.Action("OpenSavedIndication", "Indications") %>",
            data: json,
            success: function(data) {
                alert(data);
                //window.location = data;
            }
        });
    }

因此,当我执行该警报时,我会得到正确的 URL:

“/Extranet/mvc/Inspirations.cfc/Economics/02559e2e-d48e-4623-b877-69f36aa8b011”

但是,如果我让它运行,我会收到一个错误页面,其中显示:

描述:HTTP 404。资源 您正在寻找(或其之一 依赖项)可能已被删除, 已更名,或者是 暂时无法使用。请 检查以下 URL 并确保 拼写正确。

请求的网址: /Extranet/mvc/Inspirations.cfc/"/Extranet/mvc/Inductions.cfc/Economics/02559e2e-d48e-4623-b877-69f36aa8b011"/E xtranet/mvc/Inspirations.cfc/"/Extranet/mvc/Inductions.cfc/Economics/02559e2e-d48e-4623-b877-69f36aa8b011"

怎么了?

编辑:

控制器操作返回代码:

return Json(Url.Action("Economics", new { id = indicationBase.ID }));
function GetOpenUrl(transactionId, legacyIndication)
    {
        var json = {
            id : transactionId,
            legacyIndication : legacyIndication
        };
         $.ajax({
            type: "POST",
            url: "<%= Url.Action("OpenSavedIndication", "Indications") %>",
            data: json,
            success: function(data) {
                alert(data);
                //window.location = data;
            }
        });
    }

So when I perform that alert, I get the correct URL:

"/Extranet/mvc/Indications.cfc/Economics/02559e2e-d48e-4623-b877-69f36aa8b011"

However, if I let it run, I get an error page that says:

Description: HTTP 404. The resource
you are looking for (or one of its
dependencies) could have been removed,
had its name changed, or is
temporarily unavailable. Please
review the following URL and make sure
that it is spelled correctly.

Requested URL:
/Extranet/mvc/Indications.cfc/"/Extranet/mvc/Indications.cfc/Economics/02559e2e-d48e-4623-b877-69f36aa8b011"/Extranet/mvc/Indications.cfc/"/Extranet/mvc/Indications.cfc/Economics/02559e2e-d48e-4623-b877-69f36aa8b011"

what is happening?

Edit:

Controller action return code:

return Json(Url.Action("Economics", new { id = indicationBase.ID }));

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤寂小茶 2024-11-07 18:09:15

我将控制器操作更改为仅返回 Id,现在我像这样重定向:

var idData = JSON.parse(data);
window.location = "Economics/" + idData.id;

似乎工作正常。

I changed the controller action to just return the Id, and now I redirect like this:

var idData = JSON.parse(data);
window.location = "Economics/" + idData.id;

Seems to work fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文