I am working on a project. I am displaying a list of services (OurServices View) and when click on particular service a view (Single View) will be displayed in which other partial view (_Facial View) will be displayed with its particular model. But I am getting an error- NullReference Exception- Object reference not set to an instance of an object. Below is the code.
await Html.PartialAsync("_Facials", new Booking());
}
_Facial - Partial View Code
@model NiyaSpa.Models.Booking
class="inner-agile-w3l-part-head">
class
="w3l-inner-h-title">Facials
"text-align:center; font-size:medium;"
>
We provide skin specific facials as listed below. Each contains 5-8 step treatments including cleansing, chemical or physical exfoliation, gel treatment, steam facial, toning and moisturizing. Our blood circulating facial massage allows products to absorb deep into the skin giving clients long lasting results.
class="row">
class="card-deck">
@foreach (var facialService in Model as IEnumerable)
Can you please change your PartialAsync as like this,
@await Html.PartialAsync("~/Encoder/MVC/_Facials.cshtml", new Booking())
I used this link for reference, https://stackoverflow.com/questions/52013771/asp-net-core-nullreferenceexception-when-just-accessing-model
Where in the 1st Parameter of PartialAsync, you need to give total path.
One more thing, In the PartialAsync method you mentioned _Facials as 1st Parameter but on the top of _Facials Partial View Code you mentioned as _Facial. So can you please check all those things and rectify if it is wrong.
Can you tell me exactly, in which line you are getting exception. Basically, this error "NullReference Exception- Object reference not set to an instance of an object" will arise when you create an instance of a class but that object is null and when you use this object in some other place then it will raise such type of error. So can you please debug in your code and check exactly where you are getting that null object.
Akash PatelPosted Jan 23, 2019, 6:02 AM
Salman BegPosted Jan 23, 2019, 6:00 AM
Akash PatelPosted Jan 23, 2019, 5:55 AM
Salman BegPosted Jan 23, 2019, 4:49 AM
Akash PatelPosted Jan 23, 2019, 4:25 AM
Salman BegPosted Jan 23, 2019, 2:30 AM