© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•11mo ago•
7 replies
morry329#

asp-net notation does not recognise attribute notation from a model class

My Rider flagged this ListingImage notation as unrecognisable in cshtml

<form enctype="multipart/form-data" >
        <div class="custom-file">
            <input asp-for="ListingImage" type="file" class="custom-file-input fileUpload" /> /*Rider does not recognise ListingImage*/ 
            <label class="custom-file-label fileLabel">Choose file</label>
        </div>
        <input type="submit" value="Submit" />
    </form>
<form enctype="multipart/form-data" >
        <div class="custom-file">
            <input asp-for="ListingImage" type="file" class="custom-file-input fileUpload" /> /*Rider does not recognise ListingImage*/ 
            <label class="custom-file-label fileLabel">Choose file</label>
        </div>
        <input type="submit" value="Submit" />
    </form>


This ListingImage came from this model class

`
public class ListingProjects_ver2
{
    
    [System.ComponentModel.DataAnnotations.Key]
    [Required]
    public int? Id { get; set; } 

    [Required]
    public string? ListingName { get; set; }

    [NotMapped]
    [Display(Name = "ListingImage")]
    [DataType(DataType.Upload)]
    public IFormFile? ListingImage { get; set; } /*This one has linked to my cshtml*/
    
    public string? ListingImageFilePath { get; set; }
}
`
public class ListingProjects_ver2
{
    
    [System.ComponentModel.DataAnnotations.Key]
    [Required]
    public int? Id { get; set; } 

    [Required]
    public string? ListingName { get; set; }

    [NotMapped]
    [Display(Name = "ListingImage")]
    [DataType(DataType.Upload)]
    public IFormFile? ListingImage { get; set; } /*This one has linked to my cshtml*/
    
    public string? ListingImageFilePath { get; set; }
}


I think this error is a beginner's mistake, I miss out something. But I need your help to find out why my cshtml does not recognise ListingImage from the model class. Could anyone point me in the right direction?

For your reference my full code https://paste.mod.gg/aplkygbhtnqj/0
BlazeBin - aplkygbhtnqj
A tool for sharing your source code with the world!
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ JSON + ASP.NET attribute usage
C#CC# / help
2y ago
Asp Net Core Authorize Attribute
C#CC# / help
4y ago
ASP.NET how does an actionmethod get my model?
C#CC# / help
2y ago