我希望在MVC
中的文件下载后重定向特定页面。在我的应用程序中,signalr已经配置好了。所以我在控制器中使用了以下代码
var hubContext = GlobalHost.ConnectionManager.GetHubContext<ChatHub>();
hubContext.Clients.All.RedirectToBatch(BatchID, Convert.ToInt32(Session["AgencyUserID"]));
return File(stream, "text/plain", (BatchName + "." + ediExtension));
在视图中我使用了以下代码
var chat = $.connection.chatHub;
chat.client.redirectToBatch = function (BatchID, AgencyUserID) {
if (currentUserID == AgencyUserID) {
var claimlist = $('#ClaimListGrid');
if (claimlist.length > 0) {
window.location = "/Billing/ClaimSummary/" + BatchID;
}
}
};
$.connection.hub.start().done();
$.connection.hub.disconnected(function () {
setTimeout(function () {
$.connection.hub.start();
}, 5000); // Restart connection after 5 seconds.
});
我认为此代码可用于在文件下载后重定向到页面。这适用于chrome本身,但在firefox中这不能正常工作。
在firefox中发生以下错误
no element found
和
Firefox can't establish a connection to the server at ws://localhost:2804/signalr/connect?transport=webSockets&clientProtocol=1.5&connectionToken=4p2zZ%2B%2F0ok4B9uAxcslDlTv4kpT%2BGbW2nav6S%2Fe5RlSqQgS2gaFr7%2BlQiIrHZu5cPapvjoeZNB8bXM6AeF%2B1b1RS0P6y%2FETaNeAC5hDQkGrwH5xgDfjDHWt%2B%2B52K7yaD&connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D&tid=10.
我应该为这个问题做些什么?