1 year ago

#299539

test-img

SpenceW

Why is the Debug.WriteLine Not Working in Asp.net MVC?

I have created a new Asp.net project to try to get information from the Pokemon API site. I created the basic model and added a scaffolded controller based on it. My plan was to use the httpclient class to get a response and test if it worked by logging the result to Debug.WriteLine. However, not only does this not show up in the output, I added a simple text message and even that won't show up. I have done all this in the Index method of the controller:

namespace PokeWebProj.Controllers
{
    public class PokemonsController : Controller
    {
        private readonly PokeWebProjContext _context;

        public PokemonsController(PokeWebProjContext context)
        {
            _context = context;
        }


        // GET: Pokemons
        public async Task<IActionResult> Index()
        {
            //HttpClient client = new HttpClient();
            //HttpResponseMessage response = await client.GetAsync("https://pokeapi.co/api/v2/pokemon/bulbasaur");
            //JsonResult pokeJson = Json(response.Content);
            //string pokeString = response.Content.ToString();
            Debug.WriteLine("Test Message");
            //Debug.Write(pokeString);
            return View(await _context.Pokemon.ToListAsync());
        }
.
.
.

Does anyone know why this is happening? I have the response code commented out for now because I just want to find out how the Debug.Writeline works first. I would greatly appreciate any help.

c#

json

asp.net-mvc

output

visual-studio-debugging

0 Answers

Your Answer

Accepted video resources