0
votes

I have a web server inside a virtual machine and a client out of it.

For the server side I'm using .NET Framework 4.6.1

This is the structure for my WEB API controller (server-side):

// GET: api/Users
    public IQueryable<Users> GetUsers()
    {
        db.Configuration.ProxyCreationEnabled = false;

        return db.Users;
    }

    // GET: api/Users/5
    [ResponseType(typeof(Users))]
    public IHttpActionResult GetUsers(string id)
    {
        db.Configuration.ProxyCreationEnabled = false;
        Users users = db.Users.Find(id);
        if (users == null)
        {
            return NotFound();
        }

        return Ok(users);
    }

If I write on the browser ( inside the virtual machine) http://localhost:50347/api/Users/id the IIS express answer me (correctly) through the browser.

The client side makes this call (typescript):

login(account: Account): Observable<Utente> { 
let apiURL = `${URL.LOGIN}/${account.username}`;                                                        
return this.http.get<Utente>(apiURL);                                                                   

that exactly call http://10.211.55.5/api/Users/id.

If I try to call http://10.211.55.5/api/Users/id directly on the browser, the browser give me this "error":

This XML file does not appear to have any style information associated with it. The document tree is shown below.

I hope someone can help me. Thank you in advance.

1
Have you checked windows eventlog to see if there are any errors logged?Pankaj Kapare
Hi, it's the first time for me in .net, where I can find the log error? Because from the server side "seems" that all works..Andrea Perelli
that exactly call http://10.211.55.5/api/Users/id ? That means you are trying to find a user whose Primary Key value is the string id ? In that case db.Users.Find will probably throw an exception. This XML file does not appear to have any style information associated with it. The document tree is shown below. isn't an error message anyway, that's shown for any XML response that doesn't have a link to a styelsheet.Panagiotis Kanavos
Did you try debugging the code? Did you try stepping into that action or setting a breakpoint? Are there any exceptions thrown while debugging?Panagiotis Kanavos

1 Answers

0
votes

I found a solution:

I modified:

  1. the connection string from: integrated security=True to user id=user_id;password=your_password.
  2. the IIS from IIS express to IIS local

and now the communication is working.

I think that the IIS was trying to connect with the db through the windows user authentication, so out of it (inside macOS) there was (probably) permissions problems. Thank you at all.