Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Call API method with name doesn't work

$
0
0

Hi

i created asp.net core mvc app by command and then i opened the app using application with Visual Studio Code, then i restore it.

I added a api controller inside Controller folder

using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc;
using System.Linq;

namespace TestOmni.Controllers
{
    [Route("api/[controller]")]
    public class OmniPageController : Controller
    {


        public OmniPageController()
        {

        }


         [HttpPost]
         [ValidateAntiForgeryToken]
        public string OCR(byte[] DocBytes)
        {
            return "working";
        }



        [HttpGet]
        public IActionResult GetAuthor()
        {
           OmniPageHelper OPH = new OmniPageHelper();
            return Ok(OPH.Test("Pooja"));
        }
    }
}

i can access the GetAuthor api method by typing the following url on browser

http://localhost:5000/api/OmniPage/

but i can't call the api method with method name

http://localhost:5000/api/OmniPage/GetAuthor

This localhost page can’t be found

No webpage was found for the web address: http://localhost:5000/api/OmniPage/GetAuthor
Search Google for localhost 5000 api OmniPage GetAuthor
HTTP ERROR 404


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>