amazon web services - Unable to Access Owin Self hosted RestApi - Deployed to AWS EC2 - Windows 2012 R2 -


following sample self hosting restapi code, have created owin. working in local machine.

i have hosted in aws-ec2, , started administrator.

i able access restapi inside instance (using chrome/ie) giving localhost url.

access inside instan

but getting bad request invalid hostname, when replace localhost public dns of instance (running within instance's browser).

instance dns name

when tried access restapi outside instance browser local machine (browser/postman), returning status 0.

accessing outside

copied code below.

class program {     static void main(string[] args) {         const string baseuri = "http://localhost:65435";         console.writeline("starting web server...");         webapp.start<startup>(baseuri);         ...     } }  public class startup {     public void configuration(iappbuilder app) {         var webapiconfiguration = configurewebapi();         app.usewebapi(webapiconfiguration);     }      private httpconfiguration configurewebapi() {         var config = new httpconfiguration();         config.routes.maphttproute(             "defaultapi",             "api/{controller}/{id}",             new { id = routeparameter.optional });         return config;     } }  public class companiescontroller : apicontroller {     public ienumerable<company> get() {         return new list<company>(){                        new company() { id = 1, name = "microsoft" },                        new company() { id = 2, name = "amazon" }                    };     } } 

i have created windows 2012 r2 - aws ec2 instance.

configured instance:

  1. to allow traffic in inbound , outbound.
  2. opened ports.
  3. i have disabled windows firewall
  4. i have tried ping dns name local machine cmd, , success.
  5. webapi using, port number - 65435 (ephemeral port)
  6. owin version - 5.2.3.0, .net version - 4.5 (4.5.2 installed on ec2 instance)
  7. changed "localhost" in code public-dns (same issue persists) , ip-address (throws exception - "exception has been thrown target of invocation.")

inbound rule

outbound rule

please me configure this.!!

you're starting webapp on localhost:

http://localhost:65435

it's started on loopback adapter , not on actual ethernet adapter you're trying access outside. need start server's ip.


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -