i added line .useurls("http://*:5000") enable clients other hosts accessing web api.
public static void main(string[] args) { var host = new webhostbuilder() .usekestrel() .usecontentroot(directory.getcurrentdirectory()) .useiisintegration() .usestartup<startup>() .useurls("http://*:5000") // added .build(); host.run(); } however, using browser access localhost:5000/api/test got error of http/1.1 400 bad request? should .useurls() compiled production?
http/1.1 400 bad request date: mon, 08 aug 2016 21:42:30 gmt content-length: 0 server: kestrel
the following messages copied visual studio output window when testing.
microsoft.aspnetcore.hosting.internal.webhost:information: request starting http/1.1 http://localhost:5000/api/test
microsoft.aspnetcore.server.iisintegration.iismiddleware:error: 'ms-aspnetcore-token' not match expected pairing token '9bca37f2-7eda-4517-9f8f-60b6cc05cf01', request rejected.
microsoft.aspnetcore.hosting.internal.webhost:information: request finished in 8.5976ms 400
you should call first .useurls() and/or .useconfig() , .useiisintegration().
when running ok under iis/iisexpress, end 2 processes. iis listening on desired port , kestrel on one. requests should go iis , forwarded kestrel (with ms-aspnetcore-token).
the call .useiisintegration() hides mapping. changes port in app , sets iis on desired port. breaks if call both methods in incorrect order.
you getting error message because kestrel expected run behind iis, , received direct request. , noticed because iis not there inject ms-aspnetcore-token header.
this issue documents issue , may solve in future releases.
Comments
Post a Comment