.NET MVC CORE

Error \"System.Invalid OperationException has been thrown\"

For solving this issue write outside of your class [Route(\"api/VillaAPI\")] using System; using Microsoft.AspNetCore.Mvc; using Villaa_API.Models; namespace Villaa_API.Controllers { [Route(\"api/VillaAPI\")] ...

J
Joynal Abedin
6
\"\"

For solving this issue write outside of your class [Route(\"api/VillaAPI\")]

using System;
using Microsoft.AspNetCore.Mvc;
using Villaa_API.Models;

namespace Villaa_API.Controllers
{
    [Route(\"api/VillaAPI\")]
    [ApiController]
    public class VillaAPIController : ControllerBase
    {
        public IEnumerable GetVillas()
        {
            return new List {
                new Villa{Id = 1, Name = \"Pool View\" },
                new Villa{Id = 2, Name = \"Beach View\" }
    };
        }
    }
}
J

Written by Joynal Abedin

Passionate about technology, code, and sharing knowledge.

0 Comments

Leave a Comment