title: The type or namespace name 'IndexModel' could not be found (are you missing a using directive or an assembly reference?)
body: <p>I am getting several of the following errors after compiling my ABP Commercial based solution.</p>
  <pre><code>Severity    Code    Description Project File    Line    Suppression State
  Error   CS0246  The type or namespace name 'IndexModel' could not be found (are you missing a using directive or an assembly reference?)    ClientsLink.IdentityServer  D:\Century\Internal\MyProduct\MyProduct\aspnet-core\src\MyProduct.IdentityServer\obj\Debug\net5.0\Razor\Pages\Index.cshtml.g.cs 215 Active
  </code></pre>
  <p>I can't tell if it is a bug in the Visual Studio 2022 application, the Roslyn compiler, or something to do with Razor, but it is intermittent. I think the key thing to point out is that the <code>Index.cshtml.g.cs</code> file is not in my solution. It is some kind of autogenerated temporary file created when I build (Note the path).</p>
  <p>Here are the contents of the file:</p>
  <pre><code>#pragma checksum &quot;D:\Century\Internal\MyProduct\MyProduct\aspnet-core\src\MyProduct.IdentityServer\Pages\Index.cshtml&quot; &quot;{ff1816ec-aa5e-4d10-87f7-6f4963833460}&quot; &quot;f43e9fc593b31efe4f68ec9898517ecb634d6927&quot;
  // &lt;auto-generated/&gt;
  #pragma warning disable 1591
  [assembly: global::Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItemAttribute(typeof(AspNetCore.Pages_Index), @&quot;mvc.1.0.razor-page&quot;, @&quot;/Pages/Index.cshtml&quot;)]
  namespace AspNetCore
  {
      #line hidden
      using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Threading.Tasks;
      using Microsoft.AspNetCore.Mvc;
      using Microsoft.AspNetCore.Mvc.Rendering;
      using Microsoft.AspNetCore.Mvc.ViewFeatures;
  #nullable restore
  #line 2 &quot;D:\Century\Internal\MyProduct\MyProduct\aspnet-core\src\MyProduct.IdentityServer\Pages\Index.cshtml&quot;
  using MyProduct.Localization;
  
  #line default
  #line hidden
  #nullable disable
  #nullable restore
  #line 3 &quot;D:\Century\Internal\MyProduct\MyProduct\aspnet-core\src\MyProduct.IdentityServer\Pages\Index.cshtml&quot;
  using Microsoft.AspNetCore.Mvc.Localization;
  
  #line default
  #line hidden
  #nullable disable
  #nullable restore
  #line 4 &quot;D:\Century\Internal\MyProduct\MyProduct\aspnet-core\src\MyProduct.IdentityServer\Pages\Index.cshtml&quot;
  using Volo.Abp.Users;
  
  #line default
  #line hidden
  #nullable disable
      [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@&quot;SHA1&quot;, @&quot;f43e9fc593b31efe4f68ec9898517ecb634d6927&quot;, @&quot;/Pages/Index.cshtml&quot;)]
      [global::Microsoft.AspNetCore.Razor.Hosting.RazorSourceChecksumAttribute(@&quot;SHA1&quot;, @&quot;25152d795852518cc499282e563bc297efeed2a9&quot;, @&quot;/Pages/_ViewImports.cshtml&quot;)]
      public class Pages_Index : global::Microsoft.AspNetCore.Mvc.RazorPages.Page
      {
          private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_0 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute(&quot;asp-controller&quot;, &quot;Logout&quot;, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
          private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_1 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute(&quot;asp-action&quot;, &quot;Index&quot;, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
          private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_2 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute(&quot;asp-area&quot;, &quot;Account&quot;, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
          private static readonly global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute __tagHelperAttribute_3 = new global::Microsoft.AspNetCore.Razor.TagHelpers.TagHelperAttribute(&quot;class&quot;, new global::Microsoft.AspNetCore.Html.HtmlString(&quot;text-center&quot;), global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
          #line hidden
          #pragma warning disable 0649
          private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperExecutionContext __tagHelperExecutionContext;
          #pragma warning restore 0649
          private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner __tagHelperRunner = new global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperRunner();
          #pragma warning disable 0169
          private string __tagHelperStringValueBuffer;
          #pragma warning restore 0169
          private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperScopeManager __backed__tagHelperScopeManager = null;
          private global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperScopeManager __tagHelperScopeManager
          {
              get
              {
                  if (__backed__tagHelperScopeManager == null)
                  {
                      __backed__tagHelperScopeManager = new global::Microsoft.AspNetCore.Razor.Runtime.TagHelpers.TagHelperScopeManager(StartTagHelperWritingScope, EndTagHelperWritingScope);
                  }
                  return __backed__tagHelperScopeManager;
              }
          }
          private global::Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Grid.AbpRowTagHelper __Volo_Abp_AspNetCore_Mvc_UI_Bootstrap_TagHelpers_Grid_AbpRowTagHelper;
          private global::Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Grid.AbpColumnTagHelper __Volo_Abp_AspNetCore_Mvc_UI_Bootstrap_TagHelpers_Grid_AbpColumnTagHelper;
          private global::Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper;
          private global::Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button.AbpLinkButtonTagHelper __Volo_Abp_AspNetCore_Mvc_UI_Bootstrap_TagHelpers_Button_AbpLinkButtonTagHelper;
          #pragma warning disable 1998
          public async override global::System.Threading.Tasks.Task ExecuteAsync()
          {
              WriteLiteral(&quot;&lt;div&gt;\n    &quot;);
              __tagHelperExecutionContext = __tagHelperScopeManager.Begin(&quot;abp-row&quot;, global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, &quot;f43e9fc593b31efe4f68ec9898517ecb634d69275150&quot;, async() =&gt; {
                  WriteLiteral(&quot;\n        &quot;);
                  __tagHelperExecutionContext = __tagHelperScopeManager.Begin(&quot;abp-column&quot;, global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, &quot;f43e9fc593b31efe4f68ec9898517ecb634d69275417&quot;, async() =&gt; {
                      WriteLiteral(&quot;\n            &lt;i class=\&quot;fa fa-user d-block\&quot; style=\&quot;color: #12b900; font-size: 10em;\&quot;&gt;&lt;/i&gt;\n&quot;);
                      WriteLiteral(&quot;            &quot;);
                      __tagHelperExecutionContext = __tagHelperScopeManager.Begin(&quot;a&quot;, global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, &quot;f43e9fc593b31efe4f68ec9898517ecb634d69275831&quot;, async() =&gt; {
  #nullable restore
  #line (13,100)-(13,111) 6 &quot;D:\Century\Internal\MyProduct\MyProduct\aspnet-core\src\MyProduct.IdentityServer\Pages\Index.cshtml&quot;
  Write(L[&quot;Logout&quot;]);
  
  #line default
  #line hidden
  #nullable disable
                      }
                      );
                      __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper = CreateTagHelper&lt;global::Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper&gt;();
                      __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper);
                      __Volo_Abp_AspNetCore_Mvc_UI_Bootstrap_TagHelpers_Button_AbpLinkButtonTagHelper = CreateTagHelper&lt;global::Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button.AbpLinkButtonTagHelper&gt;();
                      __tagHelperExecutionContext.Add(__Volo_Abp_AspNetCore_Mvc_UI_Bootstrap_TagHelpers_Button_AbpLinkButtonTagHelper);
  #nullable restore
  #line 13 &quot;D:\Century\Internal\MyProduct\MyProduct\aspnet-core\src\MyProduct.IdentityServer\Pages\Index.cshtml&quot;
  __Volo_Abp_AspNetCore_Mvc_UI_Bootstrap_TagHelpers_Button_AbpLinkButtonTagHelper.ButtonType = global::Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Button.AbpButtonType.Primary;
  
  #line default
  #line hidden
  #nullable disable
                      __tagHelperExecutionContext.AddTagHelperAttribute(&quot;abp-button&quot;, __Volo_Abp_AspNetCore_Mvc_UI_Bootstrap_TagHelpers_Button_AbpLinkButtonTagHelper.ButtonType, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
                      __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Controller = (string)__tagHelperAttribute_0.Value;
                      __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0);
                      __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Action = (string)__tagHelperAttribute_1.Value;
                      __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_1);
                      __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Area = (string)__tagHelperAttribute_2.Value;
                      __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_2);
                      await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
                      if (!__tagHelperExecutionContext.Output.IsContentModified)
                      {
                          await __tagHelperExecutionContext.SetOutputContentAsync();
                      }
                      Write(__tagHelperExecutionContext.Output);
                      __tagHelperExecutionContext = __tagHelperScopeManager.End();
                      WriteLiteral(&quot;\n        &quot;);
                  }
                  );
                  __Volo_Abp_AspNetCore_Mvc_UI_Bootstrap_TagHelpers_Grid_AbpColumnTagHelper = CreateTagHelper&lt;global::Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Grid.AbpColumnTagHelper&gt;();
                  __tagHelperExecutionContext.Add(__Volo_Abp_AspNetCore_Mvc_UI_Bootstrap_TagHelpers_Grid_AbpColumnTagHelper);
  #nullable restore
  #line 10 &quot;D:\Century\Internal\MyProduct\MyProduct\aspnet-core\src\MyProduct.IdentityServer\Pages\Index.cshtml&quot;
  __Volo_Abp_AspNetCore_Mvc_UI_Bootstrap_TagHelpers_Grid_AbpColumnTagHelper.SizeMd = global::Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Grid.ColumnSize._3;
  
  #line default
  #line hidden
  #nullable disable
                  __tagHelperExecutionContext.AddTagHelperAttribute(&quot;size-md&quot;, __Volo_Abp_AspNetCore_Mvc_UI_Bootstrap_TagHelpers_Grid_AbpColumnTagHelper.SizeMd, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
                  __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_3);
                  await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
                  if (!__tagHelperExecutionContext.Output.IsContentModified)
                  {
                      await __tagHelperExecutionContext.SetOutputContentAsync();
                  }
                  Write(__tagHelperExecutionContext.Output);
                  __tagHelperExecutionContext = __tagHelperScopeManager.End();
                  WriteLiteral(&quot;\n        &quot;);
                  __tagHelperExecutionContext = __tagHelperScopeManager.Begin(&quot;abp-column&quot;, global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, &quot;f43e9fc593b31efe4f68ec9898517ecb634d692710199&quot;, async() =&gt; {
                      WriteLiteral(&quot;\n            &lt;h2&gt;&quot;);
  #nullable restore
  #line (16,18)-(16,38) 6 &quot;D:\Century\Internal\MyProduct\MyProduct\aspnet-core\src\MyProduct.IdentityServer\Pages\Index.cshtml&quot;
  Write(CurrentUser.UserName);
  
  #line default
  #line hidden
  #nullable disable
                      WriteLiteral(&quot;&lt;/h2&gt;\n            &lt;h5 class=\&quot;text-muted\&quot;&gt;&quot;);
  #nullable restore
  #line (17,37)-(17,54) 6 &quot;D:\Century\Internal\MyProduct\MyProduct\aspnet-core\src\MyProduct.IdentityServer\Pages\Index.cshtml&quot;
  Write(CurrentUser.Email);
  
  #line default
  #line hidden
  #nullable disable
                      WriteLiteral(&quot;&lt;/h5&gt;\n            &lt;div&gt;\n                &lt;strong&gt;Roles&lt;/strong&gt;: &quot;);
  #nullable restore
  #line (19,42)-(19,78) 6 &quot;D:\Century\Internal\MyProduct\MyProduct\aspnet-core\src\MyProduct.IdentityServer\Pages\Index.cshtml&quot;
  Write(CurrentUser.Roles.JoinAsString(&quot;, &quot;));
  
  #line default
  #line hidden
  #nullable disable
                      WriteLiteral(&quot;\n                &lt;br/&gt;\n                &lt;strong&gt;Claims&lt;/strong&gt;: &lt;br/&gt;\n                &quot;);
  #nullable restore
  #line (22,18)-(22,114) 6 &quot;D:\Century\Internal\MyProduct\MyProduct\aspnet-core\src\MyProduct.IdentityServer\Pages\Index.cshtml&quot;
  Write(Html.Raw(CurrentUser.GetAllClaims().Select(c =&gt; $&quot;{c.Type}={c.Value}&quot;).JoinAsString(&quot; &lt;br /&gt; &quot;)));
  
  #line default
  #line hidden
  #nullable disable
                      WriteLiteral(&quot;\n            &lt;/div&gt;\n        &quot;);
                  }
                  );
                  __Volo_Abp_AspNetCore_Mvc_UI_Bootstrap_TagHelpers_Grid_AbpColumnTagHelper = CreateTagHelper&lt;global::Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Grid.AbpColumnTagHelper&gt;();
                  __tagHelperExecutionContext.Add(__Volo_Abp_AspNetCore_Mvc_UI_Bootstrap_TagHelpers_Grid_AbpColumnTagHelper);
  #nullable restore
  #line 15 &quot;D:\Century\Internal\MyProduct\MyProduct\aspnet-core\src\MyProduct.IdentityServer\Pages\Index.cshtml&quot;
  __Volo_Abp_AspNetCore_Mvc_UI_Bootstrap_TagHelpers_Grid_AbpColumnTagHelper.SizeMd = global::Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Grid.ColumnSize._9;
  
  #line default
  #line hidden
  #nullable disable
                  __tagHelperExecutionContext.AddTagHelperAttribute(&quot;size-md&quot;, __Volo_Abp_AspNetCore_Mvc_UI_Bootstrap_TagHelpers_Grid_AbpColumnTagHelper.SizeMd, global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes);
                  await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
                  if (!__tagHelperExecutionContext.Output.IsContentModified)
                  {
                      await __tagHelperExecutionContext.SetOutputContentAsync();
                  }
                  Write(__tagHelperExecutionContext.Output);
                  __tagHelperExecutionContext = __tagHelperScopeManager.End();
                  WriteLiteral(&quot;\n    &quot;);
              }
              );
              __Volo_Abp_AspNetCore_Mvc_UI_Bootstrap_TagHelpers_Grid_AbpRowTagHelper = CreateTagHelper&lt;global::Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Grid.AbpRowTagHelper&gt;();
              __tagHelperExecutionContext.Add(__Volo_Abp_AspNetCore_Mvc_UI_Bootstrap_TagHelpers_Grid_AbpRowTagHelper);
              await __tagHelperRunner.RunAsync(__tagHelperExecutionContext);
              if (!__tagHelperExecutionContext.Output.IsContentModified)
              {
                  await __tagHelperExecutionContext.SetOutputContentAsync();
              }
              Write(__tagHelperExecutionContext.Output);
              __tagHelperExecutionContext = __tagHelperScopeManager.End();
              WriteLiteral(&quot;\n&lt;/div&gt;&quot;);
          }
          #pragma warning restore 1998
          [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
          public ICurrentUser CurrentUser { get; private set; }
          [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
          public IHtmlLocalizer&lt;MyProductResource&gt; L { get; private set; }
          [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
          public global::Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider ModelExpressionProvider { get; private set; }
          [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
          public global::Microsoft.AspNetCore.Mvc.IUrlHelper Url { get; private set; }
          [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
          public global::Microsoft.AspNetCore.Mvc.IViewComponentHelper Component { get; private set; }
          [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
          public global::Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper Json { get; private set; }
          [global::Microsoft.AspNetCore.Mvc.Razor.Internal.RazorInjectAttribute]
          public global::Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper&lt;IndexModel&gt; Html { get; private set; }
          public global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary&lt;IndexModel&gt; ViewData =&gt; (global::Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary&lt;IndexModel&gt;)PageContext?.ViewData;
          public IndexModel Model =&gt; ViewData.Model;
      }
  }
  #pragma warning restore 1591
  </code></pre>
  <p>And here is the <code>index.cshtml</code> file that produces that file:</p>
  <pre><code>@page
  @using MyProduct.Localization
  @using Microsoft.AspNetCore.Mvc.Localization
  @using Volo.Abp.Users
  @model IndexModel
  @inject IHtmlLocalizer&lt;MyProductResource&gt; L
  @inject ICurrentUser CurrentUser
  &lt;div&gt;
      &lt;abp-row&gt;
          &lt;abp-column size-md=&quot;_3&quot; class=&quot;text-center&quot;&gt;
              &lt;i class=&quot;fa fa-user d-block&quot; style=&quot;color: #12b900; font-size: 10em;&quot;&gt;&lt;/i&gt;
              @* ReSharper disable once Mvc.ControllerNotResolved *@
              &lt;a abp-button=&quot;Primary&quot; asp-controller=&quot;Logout&quot; asp-action=&quot;Index&quot; asp-area=&quot;Account&quot;&gt;@L[&quot;Logout&quot;]&lt;/a&gt;
          &lt;/abp-column&gt;
          &lt;abp-column size-md=&quot;_9&quot;&gt;
              &lt;h2&gt;@CurrentUser.UserName&lt;/h2&gt;
              &lt;h5 class=&quot;text-muted&quot;&gt;@CurrentUser.Email&lt;/h5&gt;
              &lt;div&gt;
                  &lt;strong&gt;Roles&lt;/strong&gt;: @CurrentUser.Roles.JoinAsString(&quot;, &quot;)
                  &lt;br/&gt;
                  &lt;strong&gt;Claims&lt;/strong&gt;: &lt;br/&gt;
                  @Html.Raw(CurrentUser.GetAllClaims().Select(c =&gt; $&quot;{c.Type}={c.Value}&quot;).JoinAsString(&quot; &lt;br /&gt; &quot;))
              &lt;/div&gt;
          &lt;/abp-column&gt;
      &lt;/abp-row&gt;
  &lt;/div&gt;
  </code></pre>
  <p>And here is the associated <code>index.cshtml.cs</code> file:</p>
  <pre><code>using Microsoft.AspNetCore.Mvc;
  using Volo.Abp.AspNetCore.Mvc.UI.RazorPages;
  
  namespace MyProduct.Pages
  {
      public class IndexModel : AbpPageModel
      {
          public ActionResult OnGet()
          {
              if (!CurrentUser.IsAuthenticated)
              {
                  return Redirect(&quot;~/Account/Login&quot;);
              }
  
              return Page();
          }
      }
  }
  </code></pre>
  <p>Another strange thing is that every time I double-click on the error to open the <code>Index.cshtml.g.cs</code> file, Visual Studio locks up and I have to kill the process and restart  it.</p>
  <p>If you are familiar with MVC or with the ABP Framework, you should know that this same problem is occurring for each of my cshtml files.</p>
  <p>How can I resolve these errors? Thanks.</p>