Home > Mobile >  The view 'Index' was not found, but it actually exist
The view 'Index' was not found, but it actually exist

Time:03-08

Appears:

InvalidOperationException: The view 'Index' was not found. The following locations were searched: /Views/Films/Index.cshtml
/Views/Shared/Index.cshtml

Although the file is present on the first path:enter image description here

By Default, As the initial page action: "Index" Controller: "Films"

app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Films}/{action=Index}/{id?}");

Controller himself:

public async Task<IActionResult> Index(int? creationTeamId)
{
    var dBOnlineCinemaContext = _context.Films.Include(f => f.CreationTeam);
    if (creationTeamId == null) //start Page
        return View();
        //
}

If right-click on the method and select "Go to View", redirects to the desired View

CodePudding user response:

Check if the SDK installed is compatible with visual studio.

run the command below to see SDKs installed.:

dotnet --info 

The SDK 6.0.200 is not compatible with Visual Studio 2022 17.0.6. See here

To solve you have to use a visual studio compatible with the SDK installed.

I've had this problem too, to solve you can:

-Install the Visual Studio 17.0.1 with is compatible with 6.0.200 SDK, or

-Remove the .net SDK 6.0.200 and use 6.0.102 with visual studio 17.0.6.

For those who find this problem in future versions, try to use the compatible version of Visual Studio and .net SDK, as shown here in Visual Studio support.

  • Related