gpt4 book ai didi

asp.net-mvc - ASP.NET MVC 3.0 -- 执行处理程序 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper' 的子请求时出错

转载 作者:行者123 更新时间:2023-12-02 08:07:24 26 4
gpt4 key购买 nike

我正在使用 ASP.NET MVC 3.0 并在 *_Shared\Layout.cshtml* 中收到以下错误

Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'.

我在 @{ Html.RenderAction("Menu", "Nav"); 处收到错误}

<!DOCTYPE html>
<html>
<head>
<title>@ViewBag.Title</title>
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
</head>

<body>
<div id = "header">
<div class = "title">SPORTS STORE</div>
</div>

<div id = "categories">


@{ Html.RenderAction("Menu", "Nav"); }
</div>

<div id = "content">
@RenderBody()
</div>

</body>
</html>
<小时/>

在 Controller \NavController中:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SportsStore.Domain.Abstract;
using SportsStore.WebUI.Models;

namespace SportsStore.WebUI.Controllers
{
public class NavController : Controller
{
private IProductRepository repository;

public NavController(IProductRepository repo)
{
repository = repo;
}


public PartialViewResult Menu()
{

IEnumerable<string> categories = repository.Products
.Select(x => x.Category)
.Distinct()
.OrderBy(x => x);

return PartialView(categories);
}

}
}
<小时/>

在 Views\Nav\Menu.cshtml 中:

@model IEnumerable<string>

@
{
Layout = null;
}

@Html.ActionLink("Home", "List", "Product")

@foreach (var link in Model)
{
@Html.RouteLink(link, new
{
controller = "Product",
action = "List",
category = link,
page = 1
}
)
}

最佳答案

我可以让这个例子工作。

但是,发布的代码存在问题。请注意示例中的换行符:

@ 
{
Layout = null;
}

虽然实际上应该是

@{ 
Layout = null;
}

它会生成您引用的错误“执行处理程序'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'的子请求时出错”,这是没有帮助的,但是当我按F5时,我被带到了一个具有更好描述的页面:

Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: A space or line break was encountered after the "@" character. Only valid identifiers, keywords, comments, "(" and "{" are valid at the start of a code block and they must occur immediately following "@" with no space in between.

关于asp.net-mvc - ASP.NET MVC 3.0 -- 执行处理程序 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper' 的子请求时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9623338/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com