title: Cannot find view 'Index', although index is there - ASP.NET Core 6 MVC
body: <p>I am trying to run my asp.net application on localhost, but seem to get the following error:</p>
  <blockquote>
  <p>An unhandled exception occurred while processing the request.</p>
  <p>InvalidOperationException: The view 'Index' was not found. The following locations were searched:<br />
  /Views/Web/Index.cshtml<br />
  /Views/Shared/Index.cshtml<br />
  /Pages/Shared/Index.cshtml</p>
  </blockquote>
  <p>I have my view located in <code>Views &gt; Web &gt; Index.cshtml</code>, although I still haven't found a way to resolve this issue. I have gone through the asp.net documentation and other stackoverflow posts. Can't seem to solve the issue.</p>
  <p>Using:</p>
  <ul>
  <li>Visual Studio 2019</li>
  <li>ASP.NET Core 6</li>
  <li>Windows 10</li>
  </ul>
  <p>Here is the code in my program.cs file</p>
  <pre><code>    using UploadExcel.Context;
      using UploadExcel.Service;
      
      var builder = WebApplication.CreateBuilder(args);
      
      // Add services to the container.
      builder.Services.AddRazorPages();
      builder.Services.AddDbContext&lt;DatabaseContext&gt;();
      builder.Services.AddScoped&lt;IWebService, WebService&gt;();
      
      var app = builder.Build();
      
      // Configure the HTTP request pipeline.
      
      if (!app.Environment.IsDevelopment())
      {
          app.UseExceptionHandler(&quot;/Error&quot;);
          app.UseHsts();
      }
      
      app.UseHttpsRedirection();
      app.UseStaticFiles();
      
      app.UseRouting();
      
      app.UseAuthorization();
      
      app.UseEndpoints(endpoints =&gt;
      {
          endpoints.MapControllerRoute(
              name: &quot;default&quot;,
              pattern: &quot;{controller=Web}/{action=Index}/{id?}&quot;);
      });
      
      app.MapRazorPages();
      
      app.Run();
  </code></pre>