简体   繁体   中英

Not able to host asp .net web api on IIS

This could be a very simple thing, but still I am not able to do this. And there is no similar question on SO

I just want to host my asp .net web api over the IIS. I was working with web application years back and this used to be a trivial thing to host a web application (not sure how to host web api).

Please note that when I hit F5 and directly run it from visual studio, then it is correctly getting hosted on IIS express at this address : http://localhost:40343/api/values

I have the default web api created from the asp .net 5 web api template and I have the controller class the following location:

C:\\NewLaptopWorkspace\\ExRestAPI\\src\\ExRestAPI\\Controllers

Steps I am following:

  1. Enabling IIS on my system.
  2. Publishing my web api from visual studio using the right click and publish option (I am not sure if this step is even required, I followed this from some of the web tutorial). I am giving the path to publish as : C:\\NewLaptopWorkspace\\ExRestAPI
  3. Adding a website from the IIS. Giving the physical path as the same path where I published my website, ie C:\\NewLaptopWorkspace\\ExRestAPI
  4. Changing the .net framework version from the Application Pool to .net 4

  5. Now when I try to browse, I get the following error (Please check url, path etc in screen shot below):

在此处输入图片说明

Could someone please help out with this!

Try giving the following users access to the physical path:

  1. IIS_USRS
  2. IUSR

By right click on the folder > security tab > edit.

You are navigating to the root. You need to put in a valid address ie localhost:8080/api/user. Or whatever controller you have setup.

please try follow these steps:

  1. Start IIS Manager. To do this, click Start, click Run, type inetmgr.exe, and then click OK.
  2. In IIS Manager, expand server name, expand Web sites, and then click the website that you want to modify.
  3. In the Features view, double-click Directory Browsing.
  4. In the Actions pane, click Enable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM