路径中存在非法字符。将 Skip 和 Take 与 IEnumerable 一起使用时出错

2024-03-26

您好,我的控制器中有以下操作

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index()
{
    IEnumerable<SurveyResult> myresult = filterData();
    totalCount = myresult.Count<SurveyResult>();
    ViewBag.totalCount = totalCount;
    //myresult = myresult.Skip<SurveyResult>(100 * pageIndex).Take<SurveyResult>(100);
    return View(myresult);
}

这是我的观点

@model IEnumerable<SurveyResult>
@{
    ViewBag.Title = "Survey Results";
}
@using (Html.BeginForm())
{

    <table class="std-tbl">
        <thead>
            <tr>
                <th>
                    DEL
                </th>
                ...

                <th>
                </th>
            </tr>
        </thead>
        @Html.DisplayFor(x => x, new { pageIndex = ViewBag.index })
    </table>
}

我对 SurveyResult 有部分看法,但我不包括它,因为我认为它不相关。这是我的问题。上面的代码工作正常,但是一旦我取消注释以下行

myresult = myresult.Skip<SurveyResult>(100 * pageIndex).Take<SurveyResult>(100);

我得到“路径中的非法字符。”我认为它可以找到 SurveyResult 的部分视图。我不明白为什么当上面的行被注释时它可以找到它,但当它未注释时却不能找到它?谢谢。

这是我的堆栈跟踪

[ArgumentException: Illegal characters in path.]
   System.IO.Path.CheckInvalidPathChars(String path) +126
   System.IO.Path.Combine(String path1, String path2) +38
   System.Web.Compilation.DiskBuildResultCache.GetPreservedDataFileName(String cacheKey) +27
   System.Web.Compilation.DiskBuildResultCache.GetBuildResult(String cacheKey, VirtualPath virtualPath, Int64 hashCode, Boolean ensureIsUpToDate) +14
   System.Web.Compilation.BuildManager.GetBuildResultFromCacheInternal(String cacheKey, Boolean keyFromVPP, VirtualPath virtualPath, Int64 hashCode, Boolean ensureIsUpToDate) +200
   System.Web.Compilation.BuildManager.GetVPathBuildResultFromCacheInternal(VirtualPath virtualPath, Boolean ensureIsUpToDate) +51
   System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +68
   System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +111
   System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound) +125
   System.Web.Mvc.BuildManagerWrapper.System.Web.Mvc.IBuildManager.FileExists(String virtualPath) +29
   System.Web.Mvc.BuildManagerViewEngine.FileExists(ControllerContext controllerContext, String virtualPath) +41
   System.Web.Mvc.VirtualPathProviderViewEngine.GetPathFromGeneralName(ControllerContext controllerContext, List`1 locations, String name, String controllerName, String areaName, String cacheKey, String[]& searchedLocations) +150
   System.Web.Mvc.VirtualPathProviderViewEngine.GetPath(ControllerContext controllerContext, String[] locations, String[] areaLocations, String locationsPropertyName, String name, String controllerName, String cacheKeyPrefix, Boolean useCache, String[]& searchedLocations) +304
   System.Web.Mvc.VirtualPathProviderViewEngine.FindPartialView(ControllerContext controllerContext, String partialViewName, Boolean useCache) +130
   System.Web.Mvc.<>c__DisplayClass8.<FindPartialView>b__7(IViewEngine e) +21
   System.Web.Mvc.ViewEngineCollection.Find(Func`2 lookup, Boolean trackSearchedPaths) +127
   System.Web.Mvc.ViewEngineCollection.FindPartialView(ControllerContext controllerContext, String partialViewName) +170
   System.Web.Mvc.Html.TemplateHelpers.ExecuteTemplate(HtmlHelper html, ViewDataDictionary viewData, String templateName, DataBoundControlMode mode, GetViewNamesDelegate getViewNames, GetDefaultActionsDelegate getDefaultActions) +418
   System.Web.Mvc.Html.TemplateHelpers.TemplateHelper(HtmlHelper html, ModelMetadata metadata, String htmlFieldName, String templateName, DataBoundControlMode mode, Object additionalViewData, ExecuteTemplateDelegate executeTemplate) +1117
   System.Web.Mvc.Html.TemplateHelpers.TemplateHelper(HtmlHelper html, ModelMetadata metadata, String htmlFieldName, String templateName, DataBoundControlMode mode, Object additionalViewData) +66
   System.Web.Mvc.Html.TemplateHelpers.TemplateFor(HtmlHelper`1 html, Expression`1 expression, String templateName, String htmlFieldName, DataBoundControlMode mode, Object additionalViewData, TemplateHelperDelegate templateHelper) +117
   System.Web.Mvc.Html.TemplateHelpers.TemplateFor(HtmlHelper`1 html, Expression`1 expression, String templateName, String htmlFieldName, DataBoundControlMode mode, Object additionalViewData) +100
   System.Web.Mvc.Html.DisplayExtensions.DisplayFor(HtmlHelper`1 html, Expression`1 expression, Object additionalViewData) +57
   ASP._Page_Views_SurveyResult_Index_cshtml.Execute() in c:\Source\Test\Admin\Views\SurveyResult\Index.cshtml:163
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +207
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +81
   System.Web.WebPages.StartPage.RunPage() +19
   System.Web.WebPages.StartPage.ExecutePageHierarchy() +65
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +76
   System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +220
   System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +115
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +303
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +23
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +260
   System.Web.Mvc.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() +19
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +177
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +343
   System.Web.Mvc.Controller.ExecuteCore() +116
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +97
   System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +37
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +62
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +50
   System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) +7
   System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +60
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8969117
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

Here is the source Error:

161号线: 162行:第163行:@Html.DisplayFor(x => x, new { pageIndex = ViewBag.index })164行: 第 165 行:}


DisplayFor正在查找以 EF 生成的实现类名称命名的视图,该视图包含非法字符。

尝试打电话.ToList()在控制器中。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

路径中存在非法字符。将 Skip 和 Take 与 IEnumerable 一起使用时出错 的相关文章

随机推荐

  • 八叉树邻居搜索

    我有一个八叉树 它存储基于体素的流体 当我模拟流体时 我需要访问当前节点周围的叶子 如何实现这样的搜索 您可以假设该节点存储了一个指向其父节点的指针 也许还需要其他数据 假设每个八叉树节点还保存其在八叉树中的 3D 索引 1 及其深度 生成
  • kube proxy日志无法打开服务Nodeport

    服务类型 节点端口 问题 无法访问 clusterIP Nodeport 并找到 kube proxy pod 日志 如下所示 无法打开端口 跳过它 err listen tcp4 32060 bind 地址已在使用中 port Descr
  • 当我尝试通过 CLI 部署 Azure 云服务时,“对象引用未设置为对象的实例”

    我在 Azure PowerShell 中运行以下命令来部署我的节点项目 Publish AzureServiceProject ServiceName
  • 移动没有历史记录的 Subversion 存储库

    有很多关于使用版本历史记录移动 Subversion 历史记录的帖子 但我想做一些不同的事情 基本上 我们有一个已用作概念证明的存储库 我们希望将其存档 然而 我们想要创建一个新的存储库 其中包含一些代码的最新版本 但保存了作者历史记录 但
  • 使用 ref 并拥有 ProxyComponent 时如何访问实际组件

    我们有一个对 React 组件的引用 并且想要调用该组件的方法 当使用 ref 时 它是一个 ProxyComponent 对象 我如何将它用作我的实际组件 或者如何才能做到这一点 我看到 有属性 renderedElement 并且在属性
  • 如果选择“图像/文件”,Laravel 会验证字段吗?

    我有一个 图像 字段 类型是file并且只需要验证是否选择了图像 这意味着它也可以为空 我试过这样 avatar gt mimes jpeg jpg png gif max 100000 但这也是必需的 我仍然尝试使用参数present a
  • EF 4.3.1 与 VS 2011

    我需要知道是否可以开始在 VS 2011 中使用最新版本的 EF 4 3 1 而无需按照所述安装这些 CTP 组件here http blogs msdn com b adonet archive 2011 06 30 announcing
  • postgis如何处理使用不同SRID发送的坐标

    我正在运行 django 应用程序 并且我正在为我的数据库使用 PostGis 扩展 我试图更好地了解发送坐标时幕后发生的情况 特别是因为我正在使用转换为不同 SRID 的不同坐标系 我的问题有三个 在数据库中创建点或多边形时 django
  • 使用 pytest 在子文件夹中进行测试

    我正在使用 python pytest 来运行我的单元测试 我的项目文件夹是 Main 包含数据文件 A txt Main Tests 我运行 pytest 的文件夹 Main Tests A test 包含测试文件的文件夹 A test文
  • 如何使用 printf 制作“进度条”? [复制]

    这个问题在这里已经有答案了 许多命令行工具都实现基于文本的进度条 就像rpm安装一样 安装 45 the 随着百分比增长 同时保持在单行 我想要的是类似的东西 我需要一个进度指示器只占一行 也就是说 当百分比增长时 它被覆盖 而不是创建一个
  • pandas groupby 转置 str 列

    这就是我想做的 gt gt gt import pandas as pd gt gt gt dftemp pd DataFrame a 1 3 2 3 b a a b c d e split a b 0 1 a 1 1 a 2 1 b 3
  • Laravel 5 获取视图名称

    我正在努力获取 L5 中的视图名称 就像在 WP 中一样 我想添加特定的页面名称 视图名称 用于样式 如下所示 div class page login h1 Inloggen h1 div div class page register
  • 如何使用javascript检查网页中是否加载了Font Awesome?

    我需要检查网页中是否有 Font Awesome 如果没有 我将用 javascript 加载它 有点像 facebook sdk 检查是否存在包含 id facebook jssdk 的脚本元素 如果是 则返回 不执行任何操作 如果不存在
  • 如何使用 api 创建 PointField?

    我正在使用 django rest framework 作为 API 但是当我发出发布请求时 会向我发送以下错误 location Invalid format string or unicode input unrecognized as
  • 使用 rc.local 运行脚本:脚本有效,但在启动时无效

    我有一个需要在启动时启动的 node js 脚本and在 www data 用户下运行 在开发过程中 我总是以以下方式开始脚本 su www data c node var www php jobs manager js 我确切地看到发生了
  • 如何冻结一个线程并从另一个线程通知它?

    我需要暂停 Rust 中的当前线程并从另一个线程通知它 在Java中我会写 synchronized myThread myThread wait 并从第二个线程 恢复主线程 synchronized myThread myThread n
  • 如何在android中使用“使用共享图像”共享Intent来共享图像?

    我有一个图像厨房应用程序 在该应用程序中 我将所有图像放入drawable hdpi 文件夹中 我在活动中调用图像如下 private Integer imageIDs R drawable wall1 R drawable wall2 R
  • 使用 Ajax 写入服务器文本文件

    我一直在努力使用 Ajax 编写服务器文本文件 如果有人花点时间看一下 我将非常感激 简单来说 为什么下面的代码不将 测试数据 写入test1 txt
  • 如何确定用户登录的提供商

    我在我的应用程序中使用多种 Firebase 登录方法 Facebook Google 电话等 但用户登录后 我无法确定使用哪个提供商进行登录 我在下面尝试过 非常接近推荐解决方案 https stackoverflow com quest
  • 路径中存在非法字符。将 Skip 和 Take 与 IEnumerable 一起使用时出错

    您好 我的控制器中有以下操作 AcceptVerbs HttpVerbs Post public ActionResult Index IEnumerable