0

i want play with asp.net web api. with simple web site then i create asp.net webform type web api and run it in my local machine then i try to publish this project with out customize to check in my iis server. but it return "403 - Forbidden: Access is denied."

http://localhost:51845/

enter image description here

and this my settings iis with then same project in my machine

enter image description here

server:8080(i replace my ip server to server)

enter image description here

it have then same error with my machine and server machine, what is wrong ? Please help. Thank

remark this project Authentication -> No Auth like this

enter image description here

My web config code

<?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=301879
  -->
<configuration>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0"/>
    <add key="webpages:Enabled" value="false"/>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
  </appSettings>
  <!--
    For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.

    The following attributes can be set on the <httpRuntime> tag.
      <system.Web>
        <httpRuntime targetFramework="4.5" />
      </system.Web>
  -->
  <system.web>
    <compilation debug="true" targetFramework="4.5"/>
    <httpRuntime/>
    <pages controlRenderingCompatibilityVersion="4.0"/>
  </system.web>
  <system.webServer>
    <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>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Optimization" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="1.1.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0"/>
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35"/>
        <bindingRedirect oldVersion="1.0.0.0-1.5.2.14234" newVersion="1.5.2.14234"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
user3001046
  • 235
  • 1
  • 10
  • 28
  • This is related to user account permissions in IIS (for integrated security) or authentication roles (for forms-based authentication). Check if current user account has sufficient privileges to access target URL or page. – Tetsuya Yamamoto Jan 22 '18 at 04:33
  • @TetsuyaYamamoto Please Check again. i not make authentication in my project. but you think that happen because of auth right ? – user3001046 Jan 22 '18 at 04:40

4 Answers4

1
  1. press win+R
  2. write "InetMgr" then press enter button
  3. right click on your site and click "EditBindings"
  4. change the port to 51845 then save
  5. publish your project to site location(right click on your site and click Explore)
  6. browse http://localhost:51845/
Ahmad Hamzavi
  • 626
  • 6
  • 18
0

If you're requiring Forms Authentication, but that module isn't running, IIS just gives a 403 error because it can't get you the kind of authentication the application requires.

So you can try is setting the "Run All Managed Modules for All Requests" option under in your applicaiton's Web.config

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true"></modules>
    <handlers>
      <remove name="UrlRoutingHandler"/>
    </handlers>
  </system.webServer>
imanshu15
  • 734
  • 3
  • 21
0

You can check if the folder where you're publishing the APP have permissions to IIS. You can try to give permission to "everyone" in the security property of the folder.

If not, check the web.config of the WebAPI on the ISS and double check the auth values and configuration.

EduLopez
  • 721
  • 7
  • 18
0

when publishing if you choose Merge all outputs a single assembly, you must set a name without space or special characters i had this error and i could fix it via this solution good luck