When I load the class in the view, it gives NullException error

-2

This is the error you are giving:

Thisistheerrorlineinmycshtml

@(newHtmlString((SessaoUtil.Recuperar("TagGoogle") != null ? SessaoUtil.Recuperar("TagGoogle").ToString() : "")))

This is my using in my cshtml

@model AgaxTurSiteOficial.Entities.PackageSearchInfo

This is my PackageSearchInfo class

public class PackageSearchInfo
    {
        public int chkpacotesroteiros { get; set; }
        public int chkaereo { get; set; }
        public int chkhotel { get; set; }
        public int chkaluguelcarro { get; set; }
        public int chkcruzeiros { get; set; }
        public int chkingressos { get; set; }
        public int chkseguro { get; set; }


        public string txtDestino { get; set; }
        public string txtOrigem { get; set; }
        public string mesViagem { get; set; }
        public string datIda { get; set; }
        public string datVolta { get; set; }
        public int intAdultos { get; set; }
        public int intCriancas { get; set; }
        public int quaAdulto { get; set; }
        public int quaCrianca { get; set; }
        public int quaMaisCinco { get; set; }
        public int idGeoAreDestino { get; set; }
        public int idGeoAreOrigem { get; set; }
        public string idPacotes { get; set; }
        public string SubMit { get; set; }


        public string localPagina { get; set; }
        public string[] passos { get; set; }

    }

I honestly have another cshtml, with the same information that works. This is the default for all our pages. I'm checking the other pages, to find out where it's different, but I can not find anything. Of course something is missing, but I do not know what it is. I put everything to try to help colleagues, giving as much information, because helping the distance I know it's bone. If you are missing any more relevant information, just ask me to edit the post and send it.

Excuse me for the wrong information. The error line in my CSHTML is this.on top of Model.chkpottacks! = 0:

@{
     if (Model.chkpacotesroteiros != 0)
    {
         @Model.mesViagem
    }
     else
    {
         @Model.datIda @:<br />a @Model.datVolta
    }

}
    
asked by anonymous 10.04.2014 / 15:07

1 answer

1

Well, I know it's hard for anyone to be able to solve problems at a distance. And sometimes we have difficulty giving the most accurate information. We often post where the problem bursts, but often not where it starts. I put some things for the colleagues to analyze and they could help me in the solution, but I was not happy to post all the code, because as this forum agent can not be posting much, I prefer to try to be lean, but I actually posted parts that do not was the problem. It was there, but that was not the point. In my Action, I have the SourcePackageInfo object and assigns the variable package to that object. In the return of Action, it should look like this: return View (package); and it looked like this: return View (); There was the question. The object was not being passed to the View and therefore gave NullException error. It was not intentional, because honestly, if I had known, I would not have made the post. For us, who have the problem, even asking the question is not always easy. I rely on the understanding of all, my goal here is to help the forum to develop more and more. But I thank everyone who tried to help me and even helped me a lot. I'll mark Renan's answer, but Gypsy also deserves to have his answer marked. I do not know if I can score two, I do not think so. Up to +++.

    
11.04.2014 / 18:42