Asp.net(核心)- 导航到多个 URL
Asp.net (Core) - Navigate to Multiple URLs
使用 Custom URL Protocol
我给自己设置了一个名为 Updater 的 url,这意味着当我调用以下控制器时;
第一个例子:
public IActionResult Launch()
{
return Redirect("Updater:");
}
它在我的机器上运行一个 .exe 文件。但是我想之后将我的网页重定向到主页。应该看起来像这样;
第二个例子:
public IActionResult Launch()
{
Redirect("Updater:"); // launch my application
return View("Index"); // and return to homepage
}
或者在我看来是这样的;
第三个例子:
<a href1="@($"ETravelerUpdater:")" href2="@Url.Action("Index", "Home")">
<img data-src="holder.js/100px280/thumb?theme=vine">
</a>
有没有简单的方法来做到这一点?
编辑:第二个和第三个示例中显示的代码不起作用,它只是为了让您了解我正在努力完成的事情。
在没有看到 Updater:
操作的情况下,我对其功能做了一些假设。无论哪种方式,这都应该让您了解如何使用来自客户端的 javascript 处理多个重定向。
<script>
function myFunction() {
window.open('MyUpdaterLink.com', '_blank'); // opens in new tab
window.location.href = "MyIndexLink.com"; // opens in current window
}
</script>
<button onclick="myFunction()">
<img data-src="holder.js/100px280/thumb?theme=vine">
</button>
除 之外,我想提供一个答案,允许用户使用 javascript
在 同一标签页 上导航到多个 URL ;
@model LaunchViewModel
<a href="javascript:Launch('ETravelerUpdater:|@Model.EmployeeName|SalesQuotes|@Model.AccessLevel')">
<img data-src="holder.js/100px280/thumb?theme=sky&text=Sales%20Quotes" alt="Card image cap">
</a>
<script>
async function Launch(url) {
window.location.href = url;
await sleep(1000);
window.location.href = "./";
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
</script>
点击锚标签后,用户将导航到 url 参数,等待一秒钟后,用户将导航到第二个 url 在这种情况下是主页.
使用 Custom URL Protocol
我给自己设置了一个名为 Updater 的 url,这意味着当我调用以下控制器时;
第一个例子:
public IActionResult Launch()
{
return Redirect("Updater:");
}
它在我的机器上运行一个 .exe 文件。但是我想之后将我的网页重定向到主页。应该看起来像这样;
第二个例子:
public IActionResult Launch()
{
Redirect("Updater:"); // launch my application
return View("Index"); // and return to homepage
}
或者在我看来是这样的;
第三个例子:
<a href1="@($"ETravelerUpdater:")" href2="@Url.Action("Index", "Home")">
<img data-src="holder.js/100px280/thumb?theme=vine">
</a>
有没有简单的方法来做到这一点?
编辑:第二个和第三个示例中显示的代码不起作用,它只是为了让您了解我正在努力完成的事情。
在没有看到 Updater:
操作的情况下,我对其功能做了一些假设。无论哪种方式,这都应该让您了解如何使用来自客户端的 javascript 处理多个重定向。
<script>
function myFunction() {
window.open('MyUpdaterLink.com', '_blank'); // opens in new tab
window.location.href = "MyIndexLink.com"; // opens in current window
}
</script>
<button onclick="myFunction()">
<img data-src="holder.js/100px280/thumb?theme=vine">
</button>
除 javascript
在 同一标签页 上导航到多个 URL ;
@model LaunchViewModel
<a href="javascript:Launch('ETravelerUpdater:|@Model.EmployeeName|SalesQuotes|@Model.AccessLevel')">
<img data-src="holder.js/100px280/thumb?theme=sky&text=Sales%20Quotes" alt="Card image cap">
</a>
<script>
async function Launch(url) {
window.location.href = url;
await sleep(1000);
window.location.href = "./";
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
</script>
点击锚标签后,用户将导航到 url 参数,等待一秒钟后,用户将导航到第二个 url 在这种情况下是主页.