0
發佈後,來自(sakura.AspNetCore)的尋呼機按鈕發出錯誤的URL,缺少該網站的基礎文件夾。例如,在此視圖中:http://localhost/glide/Clientes單擊傳呼機按鈕「2」後,生成的URL爲:http://localhost/Clientes?page=2導致HTTP 404.0 - 由於缺少「/ glide」而未找到。ASP.NET MVC Core - 查看未發現後
Startup.cs
app.UseMvc(路徑=> {
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
ClientesController.cs
public async Task<IActionResult> Index(string searchString, string sortOrder, int? page)
{
ViewBag.NameSortParm = string.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
var clientes = from c in _context.ClienteBasico
select c;
if (!String.IsNullOrEmpty(searchString))
{
clientes = clientes.Where(c => c.Nome.Contains(searchString));
}
var pageNumber = (page ?? 1);
var pageSize = 5;
switch (sortOrder)
{
case "name_desc":
clientes = clientes.OrderByDescending(c => c.Nome);
break;
default:
clientes = clientes.OrderBy(c => c.Nome);
break;
}
//return View(clientes.ToList());
return View(clientes.ToPagedList(pageSize, pageNumber));
}
您如何在視圖中設置按鈕? –
在我使用的視圖中: –