When I try to add a partial view using asp.net mvc 3 and razor it just add’s a normal .cshtml file and not a partial view. has anyone had this problem before?
/Martin
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.
In Razor there is no notion of partial views as there was in WebForms. You only have templates with the
.cshtmlextension. Depending on how the controller action serves this view (with eitherreturn View()orreturn PartialView()) the_Layout.cshtmlwill be applied or not. Also if you render a template with either the Html.Partial helper this template will be considered as a partial view. Finally you have the possibility to set whether you want or not a Layout from inside the template itself. For example to disable it:So basically in Razor you have templates and you could consider partial views as templates without a layout.