You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public class CustomerDetials
{
public string FullName { get; set; }
}
public class ServiceDetials
{
public string Name { get; set; }
}
Controllers
//http://localhost/customer/details
public class CustomerController : ApiController
{
[HttpGet]
public CustomerDetials Detials()
{
return new CustomerDetials { FullName = "Full Name" };
}
}
//http://localhost/service/details
public class ServiceController : ApiController
{
[HttpGet]
public ServiceDetials Detials()
{
return new ServiceDetials{ Name = "The service" };
}
}
ArgumentException occured in RazorViewParser::GetParsedView in return _templateService.Run(view.ViewName, view.Model, null);
Object of type 'Models.ServiceDetials' cannot be converted to type 'Models.CustomerDetials'
It looks like ceche issue. But I found a workaround if I remove Layout = "~/Views/Shared/_Layout.cshtml"; line from every view I would not get that issue.
The text was updated successfully, but these errors were encountered:
Models
public class CustomerDetials
{
public string FullName { get; set; }
}
public class ServiceDetials
{
public string Name { get; set; }
}
Controllers
//http://localhost/customer/details
public class CustomerController : ApiController
{
[HttpGet]
public CustomerDetials Detials()
{
return new CustomerDetials { FullName = "Full Name" };
}
}
//http://localhost/service/details
public class ServiceController : ApiController
{
[HttpGet]
public ServiceDetials Detials()
{
return new ServiceDetials{ Name = "The service" };
}
}
Views
CustomerDetials.cshtml:
@model Models.CustomerDetials
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
Customer name is @Model.FullName
ServiceDetials.cshtml:
@model Models.ServiceDetials
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
Service name is @Model.Name
Steps to reproduce:
1)browse to http://localhost/customer/details
1.1) Succefully
2)browse to http://localhost/service/details
2.1) Failed to render
ArgumentException occured in RazorViewParser::GetParsedView in return _templateService.Run(view.ViewName, view.Model, null);
Object of type 'Models.ServiceDetials' cannot be converted to type 'Models.CustomerDetials'
It looks like ceche issue. But I found a workaround if I remove Layout = "~/Views/Shared/_Layout.cshtml"; line from every view I would not get that issue.
The text was updated successfully, but these errors were encountered: