c# - ASP.NET MVC 按钮不触发导航
问题描述
我正在学习新的 ASP.NET MVC。我正在尝试在屏幕之间设置导航,如下所示
家庭控制器.cs
public class HomeController : Controller
{
public ActionResult Welcome(string newId)
{
ViewBag.Message = "Welcome to my shop.";
return View();
}
}
欢迎.cshtml
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
@using (Html.BeginForm())
{
<h1>The shoppee</h1>
<input type="button" title="Cart" value="Shop Items" onclick="window.location.href='@Url.Action("SelectItems", "Cart") %>'" />
}
我用 SelectItems.cshtml 构建了一个新的 CartController。我已将它们添加到 routeconfig.cs。但是上面的按钮根本没有触发。我可以使用手动导航到 url
http://localhost:portnumber/Cart/SelectItems
解决方案
推荐阅读
- python-3.x - 编译器是否将静态定义移出循环?
- python - ModuleNotFoundError:将 python3 安装到本地文件夹后没有名为“_socket”的模块
- r - 为什么我在gapminder代码中找不到函数“%>%”
- linux - 通配符 sed 在同一行的其他文本中搜索/删除
- angular - 无法上传 `.flv` - 使用 ng2-file-upload 的文件
- java - 结束返回哪个方法?
- javascript - 有什么方法可以调用部分函数
- php - PHP CURL - SoapException:服务器无法识别 HTTP 标头 SOAPAction 的值
- c++ - OpenCV:FFMPEG:编解码器 id 12 和格式不支持标记 'mp4 / MP4
- angular - 其属性仅在 TypeScript 中属于 A 和 B 类型的接口?