Illegal characters in path when calling the index view from my controller

后端 未结 2 350
情书的邮戳
情书的邮戳 2020-12-17 08:42

I am receiving an ArgumentException when invoking the index action of one of my controllers and I am not sure why. The error message is the following:

Server Error

2条回答
  •  长情又很酷
    2020-12-17 09:05

    I found it finally. It is a really embarassing typo by me. I mistyped the code:

        public ActionResult Index()
        {
            var glaccounts = db.GLAccounts.ToString();
            return View(glaccounts);
        }
    

    instead of:

        public ActionResult Index()
        {
            var glaccounts = db.GLAccounts.ToList();
            return View(glaccounts);
        }
    

    Then the framework wanted to load a view file, like this:

    "~/Views/GLAccount/SELECT \r\n[Extent1].[Id] AS [Id], \r\n[Extent1].[OrgDefinitionId] AS [OrgDefinitionId], \r\n[Extent1].[GLAccountId] AS 
    [GLAccountId], \r\n[Extent1].[Name] AS [Name], \r\n[Extent1].[StartDate] AS [StartDate], 
    \r\n[Extent1].[EndDate] AS [EndDate]\r\nFROM [GLAccounts] AS [Extent1].aspx"
    

    Hopefully, I will save couple of hours of debugging for someone else by posting this :(

提交回复
热议问题