一套解决方案,多个项目
2023-09-27 14:24:30 时间
控制器
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SportsStore.Domain.Abstract;
using SportsStore.Domain.Entities;
namespace SportsStore.WebUI.Controllers
{
public class ProductController : Controller
{
private IProductRepository repository;
public ProductController(IProductRepository productRepository)
{
this.repository = productRepository;
}
public ViewResult List()
{
return View(repository.Products);
}
}
}
视图层
@using SportsStore.Domain.Entities
@model IEnumerable<Product>
@{
ViewBag.Title = "Products";
}
@foreach (var p in Model)
{
<div>
<h3>@p.Name</h3>
@p.Description
<h4>@p.Price.ToString("c")</h4>
</div>
}
修改默认路由
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace SportsStore.WebUI
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Product", action = "List", id = UrlParameter.Optional }
);
}
}
}
操蛋玩意,不懂。
相关文章
- xcode 升级到最新的11.1版本打开项目卡顿解决方案
- 解决方案:Springboot+Vue3+Mybatis+Axios 前后端分离项目中 遇见的若干报错和踩坑避坑(一)
- 前端技术栈-ES6、Vue、ElementUI,以及Vue脚手架快速构建前端项目
- vue项目--前端显示--谷歌浏览器cookie携带不了问题
- Spring Boot 项目瘦身指南,瘦到不可思议!
- 大数据项目成功的七大秘密
- 达索系统将推3DEXPERIENCE Lab 助力初创企业项目
- 达索系统推出汽车项目智能看板行业解决方案体验
- 使用IDEA快速搭建Gradle项目
- AngularJS初探:搭建PhoneCat项目的开发与测试环境
- java版飞机大战 实战项目详细步骤
- 弹层蒙版(mask),ios滚动穿透,我们项目的解决方案
- QMUI Android 致力于提高项目 UI 开发效率的解决方案
- 广州项目实施步骤III_练习使用Keepalive保证HaProxy的高可用性
- Android开源二维码识别项目zxing横屏改为竖屏识别解决方案
- WebPack在项目配置中的探索
- Html——ie打开项目,外引js,引入成功却报错:无法获取未定义或 null 引用的属性“getItem”