I've this ActionResult:
[EncryptedActionParameter]
[CheckExternalUserRegisterSigned]
public ActionResult ExpedienteIIT(int idExpediente)
{
ExpedienteContainerVM model = this.GetExpedienteVMByIdExpediente(idExpediente);
return View("ExpedienteIIT", model);
}
ExpedientIIT View: https://jsfiddle.net/pq16Lr4q/
_Layout.cshtml: https://jsfiddle.net/1ksvav43/
So when I return the view I got this error:
I tried to put console.logs to see if the view is rendered but is not rendered...
Ok the error is here:
@model PortalSOCI.WEB.ViewModels.IIT.ExpedienteContainerVM
@{
ViewBag.Title = String.Format(PortalSOCI.WEB.Resources.ExpedienteIIT.TituloExpedienteIIT, Model.Expediente.NumeroExpediente);
}
@section JavaScript /// <-------------------- ERROR
{
@Html.Raw(ViewBag.message)
@
Can you please help me.
edit: After reading your code, i feel like
should be
an other thing that I think will give you trouble is the fact that you define your "JavaScript" section in the body. This means that if any of your views you forget to add that
you'll get a
Section JavaScript not defined
error. In your case, feels like the section's definition should be in the_layout.cshtml
.This error most likely means that you have defined the JavaScript section but have not rendered it anywhere. You need to call
@RenderSection("JavaScript")
somewhere in your layout.cshtmlthe
will let you create a section called "JavaScript", but to actually "print" the content of this section to the output HTML file (that will be sent to the client) you need to call
@RenderSection("JavaScript")
. The content of the section will be printed where the call toRenderSection
is located.You need to put the missing section inside your
ExpedienteIIT
view. According to the error message, that missing section isJavaScript
.Code sample, put this at the bottom of your view:
EDIT:
Thank you for providing a code sample of your views. There is a mismatch between how the JavaScript section in your layout page is defined and how it is being included in your view.
To fix this, do either one of the following:
_Layout
page, change@RenderSection("scripts", required: false)
to@RenderSection("JavaScript", required: false)
, ORExpedienteIIT
view, change@section JavaScript
to@section scripts
The important thing is that the two should match.