c# - Cannot access WCF service using hostname IIS -


i've been facing tough issue 3 days. have wcf web api (.svc service file) deployed iis 8.5. application working , then, suddenly, after changed other minor things inside code, problem arises: can connect application inside server (using localhost). can connect outside, using server ip address. cannot, means, connect outside using server hostname. problem best understood through examples bellow:

note: application iis app inside main web site. service's uri http://myhostname/api/servicos.svc

i have searched through many websites , forums of no avail.

my web.config:

<?xml version="1.0" encoding="utf-8"?> <configuration>   <appsettings>     <add key="aspnet:usetaskfriendlysynchronizationcontext" value="true" />   </appsettings>    <system.web>     <compilation debug="true" targetframework="4.5" />     <httpruntime targetframework="4.5" />     <customerrors mode="off" />   </system.web>    <connectionstrings>     <!-- connection string goes here -->   </connectionstrings>    <system.servicemodel>     <services>       <service name="servicoweb.servico" behaviorconfiguration="wcf_behavior">         <endpoint name="" binding="webhttpbinding" contract="servicoweb.iservico" />       </service>     </services>      <behaviors>       <endpointbehaviors>         <behavior>           <webhttp automaticformatselectionenabled="true" defaultbodystyle="bare" />         </behavior>       </endpointbehaviors>        <servicebehaviors>         <behavior name="wcf_behavior">           <servicemetadata httpgetenabled="true" httpsgetenabled="true" />           <servicedebug includeexceptiondetailinfaults="true" />         </behavior>       </servicebehaviors>     </behaviors>       <protocolmapping>       <add binding="basichttpsbinding" scheme="https" />     </protocolmapping>     <servicehostingenvironment aspnetcompatibilityenabled="false" multiplesitebindingsenabled="true" />   </system.servicemodel>    <system.webserver>     <modules runallmanagedmodulesforallrequests="true">       <add name="removesvcdaurl" type="servicoweb.validacao.urlcustomizacao, servicoweb" />     </modules>         <directorybrowse enabled="true" />         <rewrite>                     <rules>                 <remove name="wordpress: https://myhostname.com" />             </rules>         </rewrite>         <handlers accesspolicy="read, execute, script" />         <security>             <requestfiltering>                 <verbs>                     <add verb="*" allowed="true" />                 </verbs>             </requestfiltering>         </security>   </system.webserver> </configuration> 

the error presented when trying access api outside (via hostname) this:

server error in '/api' application.

the resource cannot found.

description: http 404. resource looking (or 1 of dependencies) have been removed, had name changed, or temporarily unavailable. please review following url , make sure spelled correctly.

requested url: /api/servico.svc/asos/csv/09655055000104

version information: microsoft .net framework version:4.0.30319; asp.net version:4.6.1069.1

do have idea should in order fix bug?

edit: 1 more information: other apps inside same web site in iis works fine! there other web apis written in c#, 1 here, , work properly.

edit 2: thing important can access service path until service (servico.svc). so, example, when try access "http://myhostname.com/api/servico.svc?wsdl" service's metadata. so, when try access service error mentioned above.

there file named host file. when try request dn windows file. file inside c:\windows\system32\drivers\etc there host file. append below in host file (with admin mode).

server_ip_address      myhostname.com 

Comments