Error deleting ErrorViewModel in model folder

Diana Moura 26 Reputation points
2021-07-30T22:33:28.723+00:00

Goodnight!

I'm creating a project in asp.net core mvc EF, and in the tutorial I'm following it asks to delete Error deleting ErrorViewModel in model folder and when I did, it shows error, I'm using visual studio 2019 net core 5, the teacher from course already asked to delete in the project folder, bild and objet and then to do a clean in solution and rebuild, but I did all this and still presents the problem, could someone help me? 119469-captura-de-tela-1738.png

Developer technologies | ASP.NET | ASP.NET Core
{count} votes

Answer accepted by question author
  1. Anonymous
    2021-08-05T09:39:08.78+00:00

    Hi @Diana Moura , thanks for your reply and as I can't see your tutorial, I can only test in my side by creating a new dotnet 5 MVC project and deleting the ErrorViewModel.cs file.

    And certainly, there will be some error message if I press F5 to start the program, it showed that can't find ErrorViewModel in HomeController. So I comment the code in the controller which will return Error view.

    Controller action which is related to ErrorViewModel, just comment it.

    [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
    public IActionResult Error()
    {
    return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
    }

    And then I press F5 to try to start again and I see the same error message in my side:

    120745-image.png

    That comes from the _ViewImports.cshtml file, just comment the using code line.

    @using DeleteErrorModel  
    @using DeleteErrorModel.Models  
    

    After comment that 2 lines, we need to modify Error.cshtml finally. Removing or comment the @model line and those codes which using model data.

    120758-image.png

    Then press F5, and start the program successfully.


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    Best Regards,
    Tiny Wang

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Diana Moura 26 Reputation points
    2021-08-08T17:33:59.853+00:00

    tinywang-msft, I did as you taught me and the error disappeared, the system is working normally, in my project I only had there in share/Error.cshtml and I deleted that two code and it's working correctly now, thank you very much for your help, I don't know how to vote good stars for you, how do I assess that you helped me?

    1 person found this answer helpful.

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.