Error running the default ValuesController Get()

Hi, I'm using Visual Studio 2017.  I created a C# Web API with MVC checked project.  It comes  with a basic structure already.  It has the HomeController and the ValuesController cdoe in the project explorer.  Build and ran the problem and it lands and shows the Home's Index view page no problem.  However, I get error when I accessed the ValuesController Get API.  Please see the attached image.  With this message and my break point, it does reach and execute the Get() API no problem by me adding /api/Values
But then the browser would ask if I want to save or open, if I select open then I got the error.  It's having problem opening and displaying the values.json file.  

The ValuesController.Get() api doesn't return a ActionResult so I assume it doesn't need a View created and the context menu doesn't show adding view is an option to it.  Is this correct?

  I looked up the error online and it seems it'a registry corruption issue.  I'm running Visual Studio 2017 Enterprise installer again in Repair mode.  I'm hoping that would fix it or I would have to mess with the registry values.

I'm also attaching the screen cap pop up text at the bottom of the screen when I call the Get or Get id api.

Thank you
json-error.jpg
Get-err.jpg
Get-id-err.jpg
lapuccaAsked:
Who is Participating?
 
Snarf0001Commented:
It's not an error, the system is actually running perfectly fine.
WebAPI controllers are not intended to be called directly from a browser, they're meant to be called from javascript or from a different code base as a rest api.

The values that are sent back are in JSON format:
[{RecordID: 1000, Property1: "Test"}]
Or something along those lines.  IE by default will detect the json format, not know how to process it inside the browser, and kick it as a file download.  The top error just means your system doesn't know how to open a .json file.  If you set notepad or something as the default, then it would open.

If you try the same method in Chrome or FF, those ones will show you the actual data result inline.

But again, underlying item is simply that they aren't meant to be called directly from a browser.
0
 
lapuccaAuthor Commented:
Thank you!  I thought I was losing my mind!  It was working before when I ran it in other browsers.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.