Estoy trabajando en un proyecto desarrollado por algunas personas que realmente no conozco. Encontré un problema en un método POST. El modelo es realmente nulo. Parece que el modelo no aparece en la vista.
public ActionResult ConfermaRistampa(int IDTitolo, Ristampa ristampa) //Ristampa is the model
{
//some code
if (ristampa.RichiestaRistampaWeb != null) //the field "RichiestaRistampaWeb" is null
{
ristampa.RichiestaRistampa = Utilities.ConverteFileInToFileUploadInfo(ristampa.RichiestaRistampaWeb, TipiDocumenti.Documento_Generico);
}
}
//this is the code of field on the Ristampa class declaration, in the set i noticed that value is null
public System.Web.HttpPostedFileBase RichiestaRistampaWeb
{
get
{
return this.RichiestaRistampaWebField;
}
set
{
if ((object.ReferenceEquals(this.RichiestaRistampaWebField, value) != true))
{
this.RichiestaRistampaWebField = value;
this.RaisePropertyChanged("RichiestaRistampaWeb");
}
}
}
Esa es la definición completa del modelo. Es ASP.NET Core usando MVC obviamente. Noté que la mayoría de los atributos del modelo son nulos en los establecedores.
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Name = "Ristampa", Namespace = "http://schemas.datacontract.org/2004/07/RSM.SourceData.Models.Serialized")]
[System.SerializableAttribute()]
public partial class Ristampa : object, System.Runtime.Serialization.IExtensibleDataObject, System.ComponentModel.INotifyPropertyChanged
{
[System.NonSerializedAttribute()]
private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private string ComuneLicenzaField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private string DenominazioneField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private decimal ImportoOperazioneField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private RSM.BusTuristiciWeb.SourceDataReference.FileUploadInfo LibrettoDiCircolazioneField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private System.Web.HttpPostedFileBase LibrettoDiCircolazioneWebField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private RSM.BusTuristiciWeb.SourceDataReference.FileUploadInfo LicenzaField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private System.Web.HttpPostedFileBase LicenzaWebField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private string MotivazioneField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private string NumeroLicenzaField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private RSM.BusTuristiciWeb.SourceDataReference.FileUploadInfo RicevutaPagamentoField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private System.Web.HttpPostedFileBase RicevutaPagamentoWebField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private RSM.BusTuristiciWeb.SourceDataReference.FileUploadInfo RichiestaRistampaField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private System.Web.HttpPostedFileBase RichiestaRistampaWebField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private System.Nullable<System.DateTime> ScadenzaLicenzaField;
[System.Runtime.Serialization.OptionalFieldAttribute()]
private string TargaAttualeField;
[global::System.ComponentModel.BrowsableAttribute(false)]
public System.Runtime.Serialization.ExtensionDataObject ExtensionData
{
get
{
return this.extensionDataField;
}
set
{
this.extensionDataField = value;
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public string ComuneLicenza
{
get
{
return this.ComuneLicenzaField;
}
set
{
if ((object.ReferenceEquals(this.ComuneLicenzaField, value) != true))
{
this.ComuneLicenzaField = value;
this.RaisePropertyChanged("ComuneLicenza");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public string Denominazione
{
get
{
return this.DenominazioneField;
}
set
{
if ((object.ReferenceEquals(this.DenominazioneField, value) != true))
{
this.DenominazioneField = value;
this.RaisePropertyChanged("Denominazione");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public decimal ImportoOperazione
{
get
{
return this.ImportoOperazioneField;
}
set
{
if ((this.ImportoOperazioneField.Equals(value) != true))
{
this.ImportoOperazioneField = value;
this.RaisePropertyChanged("ImportoOperazione");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public RSM.BusTuristiciWeb.SourceDataReference.FileUploadInfo LibrettoDiCircolazione
{
get
{
return this.LibrettoDiCircolazioneField;
}
set
{
if ((object.ReferenceEquals(this.LibrettoDiCircolazioneField, value) != true))
{
this.LibrettoDiCircolazioneField = value;
this.RaisePropertyChanged("LibrettoDiCircolazione");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public System.Web.HttpPostedFileBase LibrettoDiCircolazioneWeb
{
get
{
return this.LibrettoDiCircolazioneWebField;
}
set
{
if ((object.ReferenceEquals(this.LibrettoDiCircolazioneWebField, value) != true))
{
this.LibrettoDiCircolazioneWebField = value;
this.RaisePropertyChanged("LibrettoDiCircolazioneWeb");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public RSM.BusTuristiciWeb.SourceDataReference.FileUploadInfo Licenza
{
get
{
return this.LicenzaField;
}
set
{
if ((object.ReferenceEquals(this.LicenzaField, value) != true))
{
this.LicenzaField = value;
this.RaisePropertyChanged("Licenza");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public System.Web.HttpPostedFileBase LicenzaWeb
{
get
{
return this.LicenzaWebField;
}
set
{
if ((object.ReferenceEquals(this.LicenzaWebField, value) != true))
{
this.LicenzaWebField = value;
this.RaisePropertyChanged("LicenzaWeb");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public string Motivazione
{
get
{
return this.MotivazioneField;
}
set
{
if ((object.ReferenceEquals(this.MotivazioneField, value) != true))
{
this.MotivazioneField = value;
this.RaisePropertyChanged("Motivazione");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public string NumeroLicenza
{
get
{
return this.NumeroLicenzaField;
}
set
{
if ((object.ReferenceEquals(this.NumeroLicenzaField, value) != true))
{
this.NumeroLicenzaField = value;
this.RaisePropertyChanged("NumeroLicenza");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public RSM.BusTuristiciWeb.SourceDataReference.FileUploadInfo RicevutaPagamento
{
get
{
return this.RicevutaPagamentoField;
}
set
{
if ((object.ReferenceEquals(this.RicevutaPagamentoField, value) != true))
{
this.RicevutaPagamentoField = value;
this.RaisePropertyChanged("RicevutaPagamento");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public System.Web.HttpPostedFileBase RicevutaPagamentoWeb
{
get
{
return this.RicevutaPagamentoWebField;
}
set
{
if ((object.ReferenceEquals(this.RicevutaPagamentoWebField, value) != true))
{
this.RicevutaPagamentoWebField = value;
this.RaisePropertyChanged("RicevutaPagamentoWeb");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public RSM.BusTuristiciWeb.SourceDataReference.FileUploadInfo RichiestaRistampa
{
get
{
return this.RichiestaRistampaField;
}
set
{
if ((object.ReferenceEquals(this.RichiestaRistampaField, value) != true))
{
this.RichiestaRistampaField = value;
this.RaisePropertyChanged("RichiestaRistampa");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public System.Web.HttpPostedFileBase RichiestaRistampaWeb
{
get
{
return this.RichiestaRistampaWebField;
}
set
{
if ((object.ReferenceEquals(this.RichiestaRistampaWebField, value) != true))
{
this.RichiestaRistampaWebField = value;
this.RaisePropertyChanged("RichiestaRistampaWeb");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public System.Nullable<System.DateTime> ScadenzaLicenza
{
get
{
return this.ScadenzaLicenzaField;
}
set
{
if ((this.ScadenzaLicenzaField.Equals(value) != true))
{
this.ScadenzaLicenzaField = value;
this.RaisePropertyChanged("ScadenzaLicenza");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public string TargaAttuale
{
get
{
return this.TargaAttualeField;
}
set
{
if ((object.ReferenceEquals(this.TargaAttualeField, value) != true))
{
this.TargaAttualeField = value;
this.RaisePropertyChanged("TargaAttuale");
}
}
}
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged(string propertyName)
{
System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
if ((propertyChanged != null))
{
propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
}
}
}
Esa es la forma:
@using (Html.BeginForm("ConfermaRistampa", "Abbonamenti", new { @IDTitolo = Request.QueryString["IDTitolo"] }, FormMethod.Post, null))
{
<br />
<table class="table table-bordered table-striped">
<thead>
<tr class="color">
<th>
@Html.Label(Risorse.Language.TargaAttuale)
</th>
<th>
@Html.Label(Risorse.Language.Motivazione)
</th>
<th>
@Html.Label(Risorse.Language.Importo)
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
@Html.DisplayFor(model => model.TargaAttuale)
</td>
<td>
@Html.DropDownListFor(model => model.Motivazione, new SelectList(motivazioni, "Key", "Value"), "[Scegli una motivazione]", new { id = "ddlMotivazione", onchange = "SetPanelMotivazione();", required = "required" })
</td>
<td>
@Html.DisplayFor(model => model.ImportoOperazione)
</td>
</tr>
</tbody>
</table>
<div class="row">
<div class="col-sm-2">
</div>
<div class="col-sm-3">
</div>
</div>
<div class="row">
<div class="col-sm-6">
@Html.Label(Risorse.Language.DichiarazioneRichiestaRistampa + ":")
@Html.TextBoxFor(model => model.RichiestaRistampaWeb, new { type = "file", required = "required" })
</div>
@*<div class="col-sm-6">
@Html.Label(Risorse.Language.LibrettoDiCircolazione + ":")
@Html.TextBoxFor(model => model.LibrettoDiCircolazioneWeb, new { type = "file", required = "required" })
</div>*@
</div>
<br />
<div id="pnlLicense" style="display:none">
<div class="row">
<div class="col-sm-3">
@Html.Label(Risorse.Language.NumeroLicenza)
@Html.TextBoxFor(model => model.NumeroLicenza)
@Html.ValidationMessage("errNumLicenza", new { @class = "text-danger" })
</div>
<div class="col-sm-3">
@Html.Label(Risorse.Language.Provincia)
@Html.DropDownList("ddlProvince", new SelectList(listaProvince, "Key", "Value"), "Seleziona la provincia", new { @id = "ddlProvince", @onchange = "javascript:GetComuni(this.value, '#ddlComuni');" })
@Html.ValidationMessage("errProvince", new { @class = "text-danger" })
</div>
<div class="col-sm-3">
@Html.Label(Risorse.Language.Comune)
@Html.DropDownListFor(model => model.ComuneLicenza, new SelectList(new List<string>()), new { id = "ddlComuni" })
@Html.ValidationMessage("errComune", new { @class = "text-danger" })
</div>
<div class="col-sm-3">
@Html.Label(Risorse.Language.ScadenzaLicenza)
@Html.TextBoxFor(model => model.ScadenzaLicenza, new { type = "text", @language = "it", @class = "datepicker-here" })
</div>
</div>
<br />
<div class="row">
<div class="col-sm-6">
@Html.Label(Risorse.Language.DocumentazioneNuovaLicenza + ":")
@Html.TextBoxFor(model => model.LicenzaWeb, new { type = "file" })
</div>
@*<div class="col-sm-6">
@Html.Label(Risorse.Language.RicevutaAvvenutaPagamento + ":")
@Html.TextBoxFor(model => model.RicevutaPagamentoWeb, new { type = "file" })
</div>*@
</div>
</div>
<div id="pnlRagSoc" style="display:none">
<h4 class="colorH4">
@Html.Label(Risorse.Language.DatiNuovoIntestatario)
</h4>
<div class="row">
<div class="col-sm-4">
@Html.Label(Risorse.Language.Denominazione)
@Html.TextBoxFor(model => model.Denominazione)
@Html.ValidationMessage("errDenominazione", new { @class = "text-danger" })
</div>
</div>
</div>
<br />
<div class="row">
<div class="col-sm-8"></div>
<div class="col-sm-4">
<input type="submit" value="@Risorse.Language.Invia" class="btnRegister btn btn-default" />
<input type="button" value="@Risorse.Language.Annulla" onclick="Annulla();" class="btnRegister btn btn-default" />
</div>
</div>
}
En su formulario cshtml, establezca el enctype en 'multipart / form-data'. De lo contrario, los archivos no se incluirán en su modelo:
// Magic all the way to the right -->
@using (Html.BeginForm("ConfermaRistampa", "Abbonamenti", new { @IDTitolo = Request.QueryString["IDTitolo"] }, FormMethod.Post, new { enctype="multipart/form-data" }))
La estrella de HGTV, Christina Hall, revela que le diagnosticaron envenenamiento por mercurio y plomo, probablemente debido a su trabajo como manipuladora de casas.
Recientemente salió a la luz un informe policial que acusa a la estrella de 'Love Is Blind', Brennon, de violencia doméstica. Ahora, Brennon ha respondido a los reclamos.
Conozca cómo Wynonna Judd se dio cuenta de que ahora es la matriarca de la familia mientras organizaba la primera celebración de Acción de Gracias desde que murió su madre, Naomi Judd.
Descubra por qué un destacado experto en lenguaje corporal cree que es fácil trazar "tales paralelismos" entre la princesa Kate Middleton y la princesa Diana.
Los inodoros arrojan columnas de aerosol invisibles con cada descarga. ¿Como sabemos? La prueba fue capturada por láseres de alta potencia.
Air travel is far more than getting from point A to point B safely. How much do you know about the million little details that go into flying on airplanes?
The world is a huge place, yet some GeoGuessr players know locations in mere seconds. Are you one of GeoGuessr's gifted elite? Take our quiz to find out!
¿Sigue siendo efectivo ese lote de repelente de insectos que te quedó del verano pasado? Si es así, ¿por cuánto tiempo?
Durante mucho tiempo, el mundo se ha reído de la voz de Peter Dinklage actuando en Destiny, un videojuego sobre la lenta e inevitable progresión de la muerte. Pronto, esa actuación de voz va a cambiar.
Tapas elásticas de silicona de Tomorrow's Kitchen, paquete de 12 | $14 | Amazonas | Código promocional 20OFFKINJALids son básicamente los calcetines de la cocina; siempre perdiéndose, dejando contenedores huérfanos que nunca podrán volver a cerrarse. Pero, ¿y si sus tapas pudieran estirarse y adaptarse a todos los recipientes, ollas, sartenes e incluso frutas en rodajas grandes que sobran? Nunca más tendrás que preocuparte por perder esa tapa tan específica.
Hemos pirateado algunas ciudades industriales en esta columna, como Los Ángeles y Las Vegas. Ahora es el momento de una ciudad militar-industrial-compleja.
Un minorista está enlatando su sección de tallas grandes. Pero no están tomando la categoría solo en línea o descontinuándola por completo.
El equipo está a la espera de las medallas que ganó en los Juegos Olímpicos de Invierno de 2022 en Beijing, ya que se está resolviendo un caso de dopaje que involucra a la patinadora artística rusa Kamila Valieva.
Miles de compradores de Amazon recomiendan la funda de almohada de seda Mulberry, y está a la venta en este momento. La funda de almohada de seda viene en varios colores y ayuda a mantener el cabello suave y la piel clara. Compre las fundas de almohada de seda mientras tienen hasta un 46 por ciento de descuento en Amazon
El jueves se presentó una denuncia de delito menor amenazante agravado contra Joe Mixon.
El Departamento de Policía de Lafayette comenzó a investigar a un profesor de la Universidad de Purdue en diciembre después de recibir varias denuncias de un "hombre sospechoso que se acercaba a una mujer".
Al igual que el mundo que nos rodea, el lenguaje siempre está cambiando. Mientras que en eras anteriores los cambios en el idioma ocurrían durante años o incluso décadas, ahora pueden ocurrir en cuestión de días o incluso horas.
Estoy de vuelta por primera vez en seis años. No puedo decirte cuánto tiempo he estado esperando esto.
“And a river went out of Eden to water the garden, and from thence it was parted and became into four heads” Genesis 2:10. ? The heart is located in the middle of the thoracic cavity, pointing eastward.
Creo, un poco tarde en la vida, en dar oportunidades a la gente. Generosamente.