【问题标题】:System.Xml.XmlException: Reference to undeclared entity 'nbsp'System.Xml.XmlException:引用未声明的实体“nbsp”
【发布时间】:2019-01-03 09:48:01
【问题描述】:

我是 ASP.Net 的初级开发人员,但我遇到了错误: “引用未声明的实体‘nbsp’。第 69 行,第 41 位。”

我有两个几乎相同的功能:

  public async Task<IEnumerable<ContactEcocert>> GetContactsEcocertAsync(Guid entityId)
            {
                RestRequest request = new RestRequest { Resource = "Entity/{entityId}/MyContactsEcocert" };
                request.AddParameter("entityId", entityId, ParameterType.UrlSegment);

                return await RestHelper.ExecuteAsync<List<ContactEcocert>>(request);
            }
    public async Task<IEnumerable<ContactEcocertSubsidiary>> GetContactSubsidiariesByEntityAsync(Guid entityId)
        {
            RestRequest request = new RestRequest { Resource = "Entity/{entityId}/contactSubsidiary" };
            request.AddParameter("entityId", entityId, ParameterType.UrlSegment);
            try
            {
                return await RestHelper.ExecuteAsync<List<ContactEcocertSubsidiary>>(request);
            }
            catch (Exception ex)
            {
                Trace.TraceError($"Erreur lors de la récupèration des filiales lié a l'entitée courante  {entityId} : {ex.Message}");
                throw;
            }
        }

第二个犯了这个错误:

“Reference to undeclared entity 'nbsp'. Line 69, position 41.”

我不知道在哪里可以找到第 69 行第 41 行,当我使用 Ctrl+F 查找“nbsp”时,我在代码中的任何地方都找不到它。

错误出现在该行:

return await RestHelper.ExecuteAsync<List<ContactEcocertSubsidiary>>(request);

我想检查我的文件 xml 但我不知道怎么做? 有什么可以搜索的想法吗?

【问题讨论】:

标签: c# asp.net-mvc rest


【解决方案1】:

nbsp;此处列出了其他 html 实体:https://www.w3schools.com/html/html_entities.asp
这应该是您问题的正确答案。

【讨论】:

  • 但是我并没有在任何地方使用 &nsbp ......所以怎么可能出现这个错误?
  • 可能来自request.AddParameter("entityId", entityId, ParameterType.UrlSegment);确定在调用其他函数之前没有更改 entityId?
  • 哇,我只是在 ID 中更改了 entityId(以前是这样,但我确信它不会改变任何东西...)非常感谢:)
  • 你能解释一下为什么这个改变是好的吗?毕竟,变量的名称并不重要吗?在我的控制器中,我传递了参数“id”,但对于前一个函数 uit 是相同的(我传递了 id 并且我正在接收 Guid entityId : public async Task> GetContactsEcocertAsync(Guid entityId) .. .
  • 控制器代码:public async Task Index() { Guid id = HttpContext.GetCurrentEntity(); //5272af6a-3ef4-486d-8659-c069f45bf3c1 IEnumerable contactEcocert = (await _clientService.GetContactsEcocertAsync(id)).ToList(); IEnumerable contactEcocertSubsidiary = (await _clientService.GetContactSubsidiariesByEntityAsync(id)).ToList();
猜你喜欢
  • 2013-05-05
  • 1970-01-01
  • 2011-10-27
  • 1970-01-01
  • 2014-03-12
  • 2012-10-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多