Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9290151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:21:00+00:00 2026-06-18T20:21:00+00:00

I have a relatively small website that uses nested layouts. The _Layout.cshtml contains the

  • 0

I have a relatively small website that uses nested layouts.

The _Layout.cshtml contains the overall layout of the website;

  • Header
  • Menu
  • Content
  • Footer

I want the content to be loaded through Ajax but at the same time keep the website able to be navigable without it through URL. If I check in the controller if the call is Ajax and I return a ParvialView then it doesn’t render the _subLayout.cshtml that the view might be using. If I render it normally then it would ofcourse include the _subLayout.cshtml but also include the _Layout.cshtml.

How can I make the view load not the _Layout.cshtml when it is an Ajax call but do load the _subLayout.cshtml whilst keeping the _Layout.cshtml rendering intact for non-Ajax calls?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T20:21:02+00:00Added an answer on June 18, 2026 at 8:21 pm

    A little d’oh moment, I can ofcourse just do Request.IsAjaxRequest() in the _subLayout before the _Layout gets applied. Solved the issue.

    if(!Request.IsAjaxRequest())
    {
        Layout = "~/Views/Shared/_Layout.cshtml";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a relatively small database that I would like to generate a diagram
I have a relatively small app that Im building using vb.net 2.0, and nant.
I have a relatively small piece of initializer code that I want to run
I have a relatively small project (50 classes) that has included 13 JAR libraries
I have two SAS data sets. The first is relatively small, and contains unique
I have recently installed a website project on Azure and that was relatively easy
I have a small application that process a large quantity of (relatively small) files.
I have code that depends a relatively small MS Jet (created in Access) database.
I have a set of relatively simple electrical circuits. Small ones involving just resistors,
I have a relatively simple object with a method that makes an HTTP request.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.