Not able to host asp .net web api on IIS - c#

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:
Enabling IIS on my system.
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
Adding a website from the IIS. Giving the physical path as the same path where I published my website, i. e. C:\NewLaptopWorkspace\ExRestAPI
Changing the .net framework version from the Application Pool to .net 4
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:
IIS_USRS
IUSR
By right click on the folder > security tab > edit.

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

please try follow these steps:
Start IIS Manager. To do this, click Start, click Run, type inetmgr.exe, and then click OK.
In IIS Manager, expand server name, expand Web sites, and then click the website that you want to modify.
In the Features view, double-click Directory Browsing.
In the Actions pane, click Enable.

Related

Getting the Error 403.14 when running a project that uses WebAPI

At first I thought my IIS is messed up, so I uninstalled it. Now only have IIS Express.
Then I created the default ASP.NET MVC Application and was able to run it successfully with that IIS Express.
But when I am following this walk through from Microsoft website to create a WebAPI and a simple HTML page to invoke it,
HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this
directory.
is what I get. So It is not my IIS problem but I am not sure how to fix it either.
This is the example I followed, so annoying they can't write a working example in their official website.
https://www.asp.net/web-api/overview/getting-started-with-aspnet-web-api/tutorial-your-first-web-api
This problem occurs because the Web site does not have the Directory Browsing feature enabled, and the default document is not configured.
https://support.microsoft.com/en-gb/kb/942062
Method 1: Enable the Directory Browsing feature in IIS (Recommended)
To resolve this problem, follow these steps:
Start IIS Manager. To do this, click Start, click Run, type inetmgr.exe, and then click OK.
In IIS Manager, expand server name, expand Web sites, and then click the website that you want to modify.
In the Features view, double-click Directory Browsing.
In the Actions pane, click Enable.
Method 2: Add a default document
To resolve this problem, follow these steps:
Start IIS Manager. To do this, click Start, click Run, type inetmgr.exe, and then click OK.
In IIS Manager, expand server name, expand Web sites, and then click the website that you want to modify.
In the Features view, double-click Default Document.
In the Actions pane, click Enable.
In the File Name box, type the name of the default document, and then click OK.
Method 3: Enable the Directory Browsing feature in IIS Express
Note This method is for the web developers who experience the issue when they use IIS Express.
To do this, follow these steps:
Open a command prompt, and then go to the IIS Express folder on your computer. For example, go to the following folder in a command prompt:
C:\Program Files\IIS Express
Type the following command, and then press Enter:
appcmd set config /section:directoryBrowse /enabled:true

publish .net mvc to a remote windows server

I am facing a problem publishing an mvc webapi to a remote server. Currently i have deployed the website to the server and am I able to run the site in the windows server browser as a localhost however when i try to access it over the internet thought the public ip address i get a 404 error of file not found.
The port is open. i'm using iis 7.0 and windows server 2008.
I have checked all the bindings to the port! I tried to check if mvc is installed and all I read says that mvc comes already with iis 7 and webplatform installer says that .net 4.5.1 is installed
Any ideas how to solve this?
Just some simple ideas of how to resolve it. Hope they are usefull.
a) Check the app pool of the application. Set it to the correct .NET framework if required.
b) A very simple test I perform to see if its the app or the url.
- Stop the app.
- Place your app in a folder temporarily.
- Place a simple index.html HTML file where your app should be.
- Browse to it and see if 404 shows.
c) if its a new box and not set correctly you might need to set up IIS for Application Development. Check this Link with regards to setting it up. Expand the tree to make sure you select what you need.

Default mvc/webapi site works in IIS Express but not in IIS 7.5

I've googled and searched stackoverflow, the following were not helpful
RESTFul service works in IIS Express / VS2013 but not on IIS Server
- the hot fix when run says "The update is not applicable to your computer."
Different result in IIS express and IIS
- not running dotnetnuke or webmatrix
running Win7Pro, with IIS7.5 Have VS2013Pro udpate 3 installed, had VS14CTP installed but is now uninstalled.
Create a new project, chose Web Application, MVC+WebApi, have WebApi 2.2 installed via nuget.
Make no changes to app, hit F5, app starts in chrome, see default ASP.NET site with a link to home and api. Clicking the Api link takes you to a help page describing the api calls available.
Publish site to file system, create new IIS website, point site to published folder, add defaultAppPool user to folder. browse to site from within IIS Manager. Site displayes but no styles are displayed. Setup site as machinename:80 also tried machinename:50102. Not using SSL or any authentication.
In chrome console there are 3 errors (this does not happen in IISExpress)
Uncaught SyntaxError: Unexpected token < modernizr:1
Uncaught SyntaxError: Unexpected token < jquery:1
Uncaught SyntaxError: Unexpected token < bootstrap:1
Trying to navigate to the api link, just refreshes the page, the help page is not displayed.
Using fiddler to try to hit one of the services in IIS Express works as expected. Using fiddler to try to hit any of the servcies returns the default home page.
Please recall no changes made to code, just the default mvc+webapi solution created.
Checked application_start(), it contains
GlobalConfiguration.Configure(WebApiConfig.Register); as the second line.
Any help would be appreciated.
It basically comes down to how you created the solution. In visual studio 2013 Professional, File->New Project -> Visual C# -> Web -> ASP.NET Web Application Click OK. In the pop up under "Add folders and core refrences for:" MVC is checked and greyed out, you cannot un-select it. Check "Web API" check box, click ok. All will work fine while working in VS. However once published as release. Point IIS at published folder, if needed, navigate to page. Page loads but has errors as described above.
To avoid this, do not check the "Web API" check box when creating the new project. Add Web API to the solution after creating it, not during the creation.
VS version 12.0.31101.0 Update 4
.NET version 4.5.52747

C# ASP.NET can not reload web application

i can not reload the WebApplication project, i got this message error
i moved the server to another place, so the IP is changed.
i already change the ip on IIS and WebApp config
i already uninstall IIS and reinstall
i already use aspnet_reggis -i
but still i, can not reload the WebApplication.
thanks you in advance
PS: i m sure is because the IP configuration. it work well at my home, now i bring the computer to office...it not work anymore....nothing change just the IP my home is not the same like IP in my office
the error message says: the project web ESPTEMPS_WebApp is configured for IIS, the website is not found.
You most likely need to configure your IIS for your website.
here's a helpful link to do this: http://msdn.microsoft.com/en-us/library/cek8kw6e.aspx
Good luck,
Your application is configured to work with IIS, in your case, IIS is not installed in your system or maybe the developer used IIS Express when developing. (You need to install VS 2010 sp1 to get IIS Express 7.5 integration with VS)
What you can do is:
Close your solution and open the csproj file in notepad (of the project that is giving problems)
Find and set these values:
<UseIIS>False</UseIIS>
<UseIISExpress>False</UseIISExpress>
Then reopen your solution again with visual studio. You will be able to debug with the web developer web server.
I found a very good reference for you. It will walk your through set of steps to help you configure your IIS. Here is the link. Please ignore the steps that are not applicable to you. But basic idea is:
Open Project Properties and go to Web tab
Select local IIS web server. If it is already selected, it will show you a virtual directory. If it doesn't already show selected, then mention the virtual directory.

how to run my webapplication on the server ASP.NET

I have created a web application using Visualstudio 2008 using C# on my computer.
I am using windows server 2003.
I have now published the webapplication and put those contents in the server.. with a field called inetpub\wwwroot.
i have created a root directory for it in the IIS with the name "super".
Now i need to see this in internetexplorer how do i do this...
I am new to this so please help me..
Thanks
Is there a Procedure on how to do all this from the start...
If you have created a .net website or .net web application, you can follow these instructions on Deploying ASP.NET Applications in IIS 6.0. In overview, when you do a publish from visual studio, you're compiling the application down to it's assemblies, you're stripping out the code behind files, and only moving over what is needed to run the site/application. Your webserver should be setup with a virtual directory pointing to the published folder, and it would be a good idea to have a Default.aspx page in the folder since the webserver looks for this page as it's starting point. Usually the default website is the site used inside of IIS for websites (at least when you've only got one). You should be able to right click on a file and browse the file if you have followed all of the setup instructions found in the referenced link.
Good luck, and hope this helps.
Within IIS, you could right click on default.asp and select browse.

Categories