Asp.net mvc asp.net mvc控制器操作方法中未发生重定向
现在项目文件夹中有两个视图 视图1:索引 视图2:项目索引 项目索引Asp.net mvc asp.net mvc控制器操作方法中未发生重定向,asp.net-mvc,Asp.net Mvc,现在项目文件夹中有两个视图 视图1:索引 视图2:项目索引 项目索引 Public class ItemController : Controller { public ActionResult Index() { return View("Index"); } public ActionResult ItemDescription() { return View("ItemIndex"); } } @{ V
Public class ItemController : Controller
{
public ActionResult Index()
{
return View("Index");
}
public ActionResult ItemDescription()
{
return View("ItemIndex");
}
}
@{
ViewBag.Title=“ItemIndex”;
Layout=“~/Views/Shared/_Layout.cshtml”;
}
项目索引
函数重定向到详细信息()
{
$.ajax({
url:'@url.Action(“索引”,“项目”)',
类型:“POST”
});
}
现在的问题是,我在ItemIndex视图中有一个按钮,通过单击我想要重定向到Index视图的视图,这并没有发生
有什么建议吗?只需使用
window.location.href
<代码>$。ajax不会重定向您
@{
ViewBag.Title = "ItemIndex";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>ItemIndex</h2>
<input type="button" value="Next" onclick="redirecttodetails()" />
<script type="text/javascript">
function redirecttodetails()
{
$.ajax({
url: '@Url.Action("Index", "Item")',
type: 'POST'
});
}
</script>
只需使用
window.location.href
<代码>$。ajax不会重定向您
@{
ViewBag.Title = "ItemIndex";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>ItemIndex</h2>
<input type="button" value="Next" onclick="redirecttodetails()" />
<script type="text/javascript">
function redirecttodetails()
{
$.ajax({
url: '@Url.Action("Index", "Item")',
type: 'POST'
});
}
</script>
只需使用
window.location.href
<代码>$。ajax不会重定向您
@{
ViewBag.Title = "ItemIndex";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>ItemIndex</h2>
<input type="button" value="Next" onclick="redirecttodetails()" />
<script type="text/javascript">
function redirecttodetails()
{
$.ajax({
url: '@Url.Action("Index", "Item")',
type: 'POST'
});
}
</script>
只需使用
window.location.href
<代码>$。ajax不会重定向您
@{
ViewBag.Title = "ItemIndex";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>ItemIndex</h2>
<input type="button" value="Next" onclick="redirecttodetails()" />
<script type="text/javascript">
function redirecttodetails()
{
$.ajax({
url: '@Url.Action("Index", "Item")',
type: 'POST'
});
}
</script>
Ajax不会将您重定向到新页面。将其更改为:
function redirecttodetails()
{
window.location.href = '@Url.Action("Index", "Item")';
}
Ajax不会将您重定向到新页面。将其更改为:
function redirecttodetails()
{
window.location.href = '@Url.Action("Index", "Item")';
}
Ajax不会将您重定向到新页面。将其更改为:
function redirecttodetails()
{
window.location.href = '@Url.Action("Index", "Item")';
}
Ajax不会将您重定向到新页面。将其更改为:
function redirecttodetails()
{
window.location.href = '@Url.Action("Index", "Item")';
}
@用户2465036,很高兴我能help@user2465036,很高兴我能help@user2465036,很高兴我能help@user2465036,很高兴我能帮上忙,谢谢解决方案有效。但我不能同时更正两个答案。看起来他比你早回答了一分钟。无论如何,多谢了,谢谢。解决方案正在发挥作用。但我不能同时更正两个答案。看起来他比你早回答了一分钟。无论如何,多谢了,谢谢。解决方案正在发挥作用。但我不能同时更正两个答案。看起来他比你早回答了一分钟。无论如何,多谢了,谢谢。解决方案正在发挥作用。但我不能同时更正两个答案。看起来他比你早回答了一分钟。无论如何,非常感谢