Could i include a single page .cshtml in a MVC3 app (without controller)? I have some static pages but i like to use our base layout.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Yes, you can. For example include
index.cshtmlwith the following contents in the root of your web site:and then navigate to
/index.cshtml.Bare in mind that cshtml pages are not allowed in the
~/Viewsfolder so make sure you don’t put outside. TheViewsfolder is a special one and is controlled by the~/Views/web.configin which the base type for Razor views is changed toSystem.Web.Mvc.WebViewPagebecause those are MVC views and also they cannot be served directly.So you could have 2 types of templates:
~/Viewsfolder)This being said, you cannot use your
~/Views/Shared/_Layout.cshtmlwith a WebPage. It can only be used with ASP.NET MVC views.