Thank you for your response, I'm just taking the example of the documentation that you share with me.
However I managed to solve the problem by removing the IEnumerable and it worked so far, I still have confusion about using and how to use the IEnumerable but I think I can continue for the moment.
I already applied the solution you gave me, but the error still appears in the foreach, however, I have eliminated the IEnumerable and it works well for me. Do you know why this happens?
Ah ok - Just wanted to make sure. But it occurs to me that some of the examples might not have been correct? Do you mind referencing the part of the documentation where you got stuck? Because then it's possible to have it updated with the correct way of going about it so others don't face the same issues that you have experienced :-)
IEnumerable is an interface that exposes the Enumerator. Your model is something different. Your model is basically a data dump of variables that you can use in views when they get populated
namespace MVC_BasicTutorials.Models
{
public class Student
{
public int StudentId { get; set; }
public string StudentName { get; set; }
public int Age { get; set; }
}
}
Then in a view you can do this:
@model Student
<h1>@Model.StudentId</h1>
You can find IEnumerable here
To put it as simply as I can, IEnumerable allows you to loop through stuff like collections.
Help with umbraco headless and .net
Hello everyone, I'm starting with the test example of 'Asp.net Framework website' and already configure the class and the controller.
But I have problems with the view, it marks me an error in the IEnumerable code line. Could someone guide me? (Attachment screenshot).
I am using Visual Studio 2017 and framework 4.6.1
To resolve your issue, you need to specify the type of your
IEnumerable
, as well as including your@using
statement at the top of your file, like so:Hi Uriel
I have not been playing aorund with Headles and .NET myself but I just want to make sure you're aware that there is some documentation available here too? https://our.umbraco.com/documentation/Umbraco-Cloud/Headless/Headless-Net-Client/ :-)
/Jan
Hi Jan,
Thank you for your response, I'm just taking the example of the documentation that you share with me.
However I managed to solve the problem by removing the IEnumerable and it worked so far, I still have confusion about using and how to use the IEnumerable but I think I can continue for the moment.
Thanks for your time.
Hi Rhys,
I already applied the solution you gave me, but the error still appears in the foreach, however, I have eliminated the IEnumerable and it works well for me. Do you know why this happens?
Hi Uriel
Ah ok - Just wanted to make sure. But it occurs to me that some of the examples might not have been correct? Do you mind referencing the part of the documentation where you got stuck? Because then it's possible to have it updated with the correct way of going about it so others don't face the same issues that you have experienced :-)
/Jan
Of course,
Headless .NET client> ASP.NET Framework website> Create a view at /Views/Home/Headless.cshtml
I add the url too: https://our.umbraco.com/documentation/Umbraco-Cloud/Headless/Headless-Net-Client/website-framework
Thanks for your time.
Hey Uriel,
IEnumerable is an interface that exposes the Enumerator. Your model is something different. Your model is basically a data dump of variables that you can use in views when they get populated
What a model looks like:
Taken from here
Then in a view you can do this:
You can find IEnumerable here To put it as simply as I can, IEnumerable allows you to loop through stuff like collections.
Harry,
Thank you very much, you have helped me a lot, This solves my problem.
Glad I could help
is working on a reply...