0

I'm working on a ASP.NET Core Razor pages project that uses a Layout and wonder how would I return an empty page?

I tried something like

public ActionResult OnGet()
{
    return null;
}

but that only return empty section, it still show all of the layout elements.

Is there a way to return a completely empty page?

Asons
  • 84,923
  • 12
  • 110
  • 165
mko
  • 6,638
  • 12
  • 67
  • 118
  • Possible duplicate of https://stackoverflow.com/questions/39870298/how-do-i-specify-different-layouts-in-the-asp-net-core-mvc – Asons Aug 10 '19 at 21:04
  • Altough it is not a duplicate since the problem is not even close, one of the answers actually provide an idea for workaround of this problem – mko Aug 11 '19 at 05:30
  • Well, it doesn't need to be the same problem to solve, it can be one of its answers that make a post a possible duplicate, still, here's another possible duplicate of [ASP.NET MVC return empty view](https://stackoverflow.com/questions/6857607/asp-net-mvc-return-empty-view) – Asons Aug 11 '19 at 13:51
  • put this in top of your cshtml file @{ Layout = null; } and your action method must return your view file – Majid Azarniush Aug 11 '19 at 13:57

0 Answers0