1

This is my _ViewStart.cshtml:

@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

This is my _Layout.html:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - My ASP.NET Application</title>
    <link href="//netdna.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">


    <!-- Lots of tags for dependencies -->

</head>
<body>
    <div class="container body-content">
        @RenderBody()
        <div class="divider row top-buffer"></div>
        <footer>
            <p>&copy; @DateTime.Now.Year - MyApp</p>
        </footer>
    </div>
</body>
</html>

This is my Index.cshtml:

@Html.RenderApiEndpoints()
<script type="text/javascript" src="~/Content/index.js"></script>

    <div ng-app="app">
        <div ng-view ></div>
    </div>

I am fetching Index.cshtml like:

public class HomeController : Controller
    {
        [Route("")]
        public ActionResult Index()
        {
            return View();
        }
    }

Since I am using client-side routing with Angular $routeProvider, I am always in Index.cshtml. Furthermore, I don't need a Layout, I just need my Index.cshtml.

How can I avoid using a Layout-File and directly start with my Index.cshtml when going to localhost in browser?

1
  • @ testiguy did you solve problem Commented Jun 26, 2017 at 15:13

2 Answers 2

2

You can make Layout null then you will just see Index.cshtml view

@{
    Layout = null;
}
Sign up to request clarification or add additional context in comments.

3 Comments

Then I start automatically with Index.cshtml?
@testiguy Yes You can start
@testiguy did you try
1

Use null layout in the following way:

@{
    Layout = null;
}

1 Comment

this equal to my answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.