asp.net MVC,重定向到视图,视图打开新窗口到外部url,它'It’’’’我们被当成一种风景

asp.net MVC, redirect to view, view open new window to external url, it's getting treated as a view

本文关键字:视图 我们 It 一种 风景 外部 重定向 MVC net 新窗口 url      更新时间:2023-09-26

试图将一个快速而肮脏的页面放在一起,以便在新窗口中重定向到另一个网站。

所以我在会话中隐藏了一个url,从mvcSiteMap重定向到页面,点击页面。。。

运行此javascript

    $(document).ready(function () {
        window.open( '@HttpContext.Current.Session["EisUrl"].ToString();' );
    });

</script>

}

我没有打开一个指向google.com的新窗口,而是收到了带有这条消息的同一个窗口。

视图'http://google.com'或未找到其主控形状,或者没有视图引擎支持搜索的位置。搜索了以下位置:~/Views/ReportsManagement/http://google.com.aspx~/Views/ReportsManagement/http://google.com.ascx~/视图/共享/http://google.com.aspx~/视图/共享/http://google.com.ascx~/Views/ReportsManagement/http://google.com.cshtml~/Views/ReportsManagement/http://google.com.vbhtml~/视图/共享/http://google.com.cshtml~/视图/共享/http://google.com.vbhtml

因此,它将我的外部URL视为网站内部的URL。。。

这似乎应该很简单。。。。。很明显,我错过了一些显而易见的东西。

感谢您的帮助。

确保从会话中呈现的内容是您所期望的正确且格式正确的URL。我通常也使用window.location在javascript中重定向。

可能完全超出范围,但你不能在ActionResult中做到这一点吗?

return Redirect("http://www.google.com");

尝试

window.location = '@HttpContext.Current.Session["EisUrl"].ToString()';

我发现了,我是一个身份证10 t,

我看到了这个(剃须刀)

@model string

在控制器中

public ActionResult GetEisReportRedirect()
        {
            string url =  eisReportBLLHdl.DoGetEisReportRedirect(  );
            return View( url );// i was passing url here to the view
        }

所以它试图将字符串作为模型传递,我决定不确定确切的行为,并将其放入会话中。。但把它们留在原地。

出于某种原因,该字符串被作为URL进行了交互,新窗口没有打开的事实应该是它提前偏离轨道的线索。

当我从模型中删除行,并从返回的View()中删除url参数时。。。它现在正确重定向(只是不在新页面中,但我会得到它)

谢谢你的帮助!