title: How to Redirect Controller to razor page in ASP.NET Core
body: <p>I send data from <code>Index.cshtml</code> to my controller. Then I want to redirect from the controller to the <code>index.cshtml</code> page inside the <code>Admin</code> folder (those two are two different <code>index.cstml</code> files). I added a screenshot of the file hierarchy. Please help me to solve this.</p>
  <p>I tried this, but it's not working</p>
  <pre><code>public IActionResult Login([FromBody] Users user)
  {
      if (user.UserName.Equals(&quot;admin&quot;) &amp; user.Password.Equals(&quot;admin&quot;))
      {
          return LocalRedirect(&quot;/Admin/Index&quot;); // redirect to index page in Admin folder
      }
      else
          return RedirectToPage(&quot;Error&quot;);
  }
  </code></pre>
  <p>Folder structure:</p>
  <p><img src="https://i.stack.imgur.com/I8eGS.png" alt="folder structure for better understand" /></p>
  <p>This is startup page</p>
  <pre><code>using Microsoft.AspNetCore.Builder;
  using Microsoft.AspNetCore.Hosting;
  using Microsoft.AspNetCore.Http;
  using Microsoft.EntityFrameworkCore;
  using Microsoft.Extensions.Configuration;
  using Microsoft.Extensions.DependencyInjection;
  using Microsoft.Extensions.Hosting;
  using PracticalTest.Database;
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Threading.Tasks;
  namespace PracticalTest.UIs
  {
      public class Startup
      {
          public Startup(IConfiguration configuration)
          {
              Configuration = configuration;
          }
  
          public IConfiguration Configuration { get; }
  
          // This method gets called by the runtime. Use this method to add services to the container.
          public void ConfigureServices(IServiceCollection services)
          {
              services.AddRazorPages();
              services.AddDbContext&lt;ApplicationDbContext&gt;(options =&gt; options.UseSqlServer(Configuration[&quot;defaultConnection&quot;]));
              services.AddControllers();
          }
  
          // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
          public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
          {
              if (env.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
              }
              else
              {
                  app.UseExceptionHandler(&quot;/Error&quot;);
                  // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                  app.UseHsts();
              }
  
              app.UseHttpsRedirection();
              app.UseStaticFiles();
  
              app.UseRouting();
  
              app.UseAuthorization();
  
              app.UseEndpoints(endpoints =&gt;
              {
                  endpoints.MapRazorPages();
                  endpoints.MapControllers();
              });
  
          }
      }
  }
  
  </code></pre>
  <p>AdminController</p>
  <pre><code>using Microsoft.AspNetCore.Mvc;
  using PracticalTest.Application.Admin;
  using PracticalTest.Database;
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Threading.Tasks;
  
  namespace PracticalTest.UIs.Controllers
  {
      [Route(&quot;[controller]&quot;)]
      public class AdminController : Controller
      {
          private ApplicationDbContext _ctx;
          public AdminController(ApplicationDbContext ctx)
          {
              _ctx = ctx;
          }
  
          [HttpGet(&quot;Items&quot;)]
          public IActionResult GetItems() =&gt;Ok( new GetItems(_ctx).Do());
          [HttpGet(&quot;Users&quot;)]
          public IActionResult GetUsers() =&gt; Ok(new GetUsers(_ctx).Do());
  
          [HttpGet(&quot;Items/{id}&quot;)]
          public IActionResult GetItem(int id) =&gt;Ok(new GetItem(_ctx).Do(id));
  
  
          [HttpGet(&quot;Users/{id}&quot;)]
          public IActionResult GetUser(int id) =&gt; Ok(new GetUser(_ctx).Do(id));
  
          [HttpPost(&quot;Items&quot;)]
          public async Task&lt;IActionResult&gt; CreateItem([FromBody]CreateItem.Requst requst) =&gt;Ok((await new CreateItem(_ctx).Do(requst)));
          [HttpPost(&quot;Users&quot;)]
          public async Task&lt;IActionResult&gt; CreateUser([FromBody] CreateUser.Requst requst) =&gt; Ok((await new CreateUser(_ctx).Do(requst)));
  
          [HttpDelete(&quot;Items/{id}&quot;)] 
          public async Task&lt;IActionResult&gt; DeleteItem(int id) =&gt;Ok((await new DeleteItem(_ctx).Do(id)));
  
          [HttpDelete(&quot;Users/{id}&quot;)]
          public async Task&lt;IActionResult&gt; DeleteUser(int id) =&gt; Ok((await new DeleteUser(_ctx).Do(id)));
  
          [HttpPut(&quot;Items&quot;)]
          public async Task&lt;IActionResult&gt; UpdateItem([FromBody]UpdateItem.Request rq) =&gt;Ok((await new UpdateItem(_ctx).Do(rq)));
          [HttpPut(&quot;Users&quot;)]
          public async Task&lt;IActionResult&gt; UpdateUser([FromBody] UpdateUser.Request rq) =&gt; Ok((await new UpdateUser(_ctx).Do(rq)));
  
         
      }
  }
  
  </code></pre>