c# - My WebApi works fine on Visual Studio but doesn't work on IIS -


there bunch of same questions find in , on internet. non of them solution issue (at least solutions have seen far). need help.

i have created webapi following listings works fine when run visual studio. doesn't work when publish iis of own machine.

it gives me http error 404.0 - not found error.

  • operating system: windows 7
  • ide: visual studio 2013
  • iis: version 7.5

this system.webserver , applicationsettings part of web.config:

          <system.webserver>             <validation validateintegratedmodeconfiguration="false"/>             <modules runallmanagedmodulesforallrequests="true"/>              <handlers>               <remove name="extensionlessurlhandler-integrated-4.0" />               <remove name="optionsverbhandler" />               <remove name="traceverbhandler" />               <add name="extensionlessurlhandler-integrated-4.0" path="*." verb="*"      type="system.web.handlers.transferrequesthandler"  precondition="integratedmode,runtimeversionv4.0" />             </handlers>           </system.webserver>           <applicationsettings>             <sampleaspnetwebapi.properties.settings>               <setting name="authorityaddress" serializeas="string">                 <value>https://localhost:44333/core</value>               </setting>               <setting name="sampleaspnetwebapi_smspanel_sms" serializeas="string">                 <value>http://something.com/smsws/soap.asmx</value>               </setting>             </sampleaspnetwebapi.properties.settings>           </applicationsettings> 

this routing map:

    config.routes.maphttproute(         name: "defaultapi",         routetemplate: "{controller}/{action}",         defaults: new { id = routeparameter.optional }     ); 

finally controller have created testing purpose:

public class testcontroller : apicontroller {     public string get()     {         return "just test";     } } 

update:

application advance settings

enter image description here

in iis/websits's hostname, need add hostname e.g. mytestapi (the last picture shared iis settings)

then add system's host file (c:\windows\system32\drivers\etc\hosts):

127.0.0.1 mytestapi

then test api url:

http://mytestapi/api/yourapicontroller


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -