Web API IIS deployment and 403 errors - c#

I have managed to create a deployment package and install it on IIS. It is not serving content correctly.
The server responds appropriately when trying to hit URLs that would not be routed to the Web API application, or when the request doesn't make sense. For instance, trying to hit a non existent url gives a 404, or making a GET request to a route that only supports POST returns 405 method not allowed with this message:
{
"Message": "The requested resource does not support http method 'GET'."
}
All other requests are giving 403 forbidden errors. To me, this indicates routing is working correctly and there is some other configuration error. I've tried both the 'bad' and 'good' solutions listed here: http://www.britishdeveloper.co.uk/2010/06/dont-use-modules-runallmanagedmodulesfo.html, neither made any difference.
I noticed that the application has not created the user database tables, as it did automatically when I ran the application for the first time. I figured this may be related.
I believe IIS is correctly configured; it has .NET 4 and integrated mode for the application pool. I have confirmed that ASP.NET 4.5 is installed via the Add/Remove Windows Features dialog.
The application I am trying to host is based on: https://github.com/MikeWasson/LocalAccountsApp. I have made very minimal changes. Everything works fine locally.
Server stats:
Windows Server 2012 R2
SQL Server 2016
IIS 8.5

So, the underlying issue was I had not set up a https binding for the site. This was obscured by a few things, mainly that the endpoints were acting inconsistently. One end point was redirected by IIS or Web API to the https binding (presumably because of some setting enforcing it), while another was quite happy to serve me 403/405 errors above.

Related

HTTP 503 error when behind ZScaler corporate proxy and trying to access web app

A couple of days ago our web app started showing a 503 error when trying to access our web app. It works fine when ZScaler is off. This is an old app running .NET MVC 5 on a Windows Server 2012 machine. No changes were made from our side when the issue started happening, so I was suspecting that the networking team had done something. However, they cannot seem to locate the issue.
When trying to access the page through Chrome, I get a HTTP 503 error, but on Firefox it shows a blank page and says that the connection is not secure. I can access the web app through the server hostname URL fine. However, when trying to use the registered domain name, it is displaying this error. I have checked the logs on the server, but it isn't showing anything specific to this error.
Does anyone know what this could be? Is there anything in IIS that I should look at specifically?
I have checked the logs on the server, but it isn't showing anything specific to this error.
An HTTP 503 error usually indicates that the server is currently not able to handle the request due to maintenance or capacity issues. It could be caused due to many factors, like a server outage, an issue with the network, or a problem with the application itself.
Here are a few things you can try to troubleshoot the issue:
Check the IIS logs, IIS logs are located in the
C:\inetpub\logs\LogFiles folder by default.
Check the event logs, event logs can be accessed through the
Event Viewer (eventvwr.msc).
Try accessing the web app using the server's IP address instead of
the registered domain name. This can help determine if the issue is
related to the domain name or the server itself.
Make sure that the application pool for the web app is running and
that the application pool identity has the necessary permissions to
access the web app's files and resources.
Check the network configuration and make sure that the server is
properly connected to the network and that there are no issues with
the network connection.
Check the web.config to make sure that it is properly
set up and that there are no issues with the web.config file.
Check the ZScaler configuration to make sure that it is not
blocking access to the web app. You may need to work with the
networking team to determine if there are any issues with the
ZScaler configuration.

C# Web service works in console but not from asp.net website on IIS server

I'm using a web service which works fine when I run it on my machine in an ASP.NET application using the default IIS Express VS 2010 comes with. However, when I move it to our server with IIS I get the error:
Error: There was no endpoint listening at 'web service name here' that could accept the message. This is often caused by an incorrect address or SOAP action.
'web service name here' is just a placeholder I put for this post. It has the right web service name.
So I pulled out the small login code that this is failing on into a console application and ran that from the IIS server and it worked! So I have to assume this is some kind of permissions issue with the IIS server on how it's running my web service code? In my ASP.NET program I have a separate DLL that handles the web service. The ASP.NET application fires off a separate thread that uses the DLL I made that uses the web service. Is it something to do with the separate thread permissions maybe? Any ideas?
Your first step when faced with this sort of issue is to search your config files for "web service name here" (or if this isn't actually the message you're getting the address given in the message). My suspicion is somewhere you'll have a WCF reference set up which needs a proper IP address.
Once you've got the address (assuming it looks valid) you need to check you can access it from the machine which is having the difficulties - it may be a firewall issue.
Now that you've established that your console application is connecting correctly from the same machine the next step is to check that both your IIS App Pool and Console application are running under the same user account/permissions. It may be that one identity has permission to access the network/internet and the other one doesn't.

The remote server returned an error: (404) Not Found.

Currently migrating a number of .NET 2.0/4.0 apps to Windows server 2008 r2, IIS7.5
One of the apps uses a web service (.asmx) but for some reason the server returns a 404 Not found and within the exception
There was no endpoint listening at [http://servername/service.asmx] that could accept the message. This is often caused by an incorrect address or SOAP action
I can navigate to the service url in the browser and see the list of web methods. So I know the service is running and accessible.
The weird thing is we have a dev environment with exactly the same setup and is working fine. I can also reference the service running on the production from the dev code and the app works as expected.
I have tried a load of the things mentioned on these sites but nothing seems to have resolved it.
Thanks in advance.

Fiddler Not Capturing Traffic from my C# Application

I am having problems capturing traffic sent and received from my C# application.
The application is an ordinary WinForms application using C# 5.0 and .NET 4.5. .
Fiddler captures traffic from Chrome and Firefox with no issues, just not my application. I have also loaded another application that I developed, and that works fine.
It may be worth noting that this is the first application I've developed that uses HttpClient to make Http requests. Could that be causing any issues?
To be clear the Fiddler Application monitors the traffic. I am not connecting to localhost. I am connect to web API's.
Step #1 is to try starting Fiddler before starting your application. This helps the default configuration, whereby .NET applications pick up the system proxy when they start and are oblivious to proxy changes after they start.
Step #2, if the first step doesn't work, is to explicitly configure your process to use the proxy by editing the app.exe.config file or the machine.config file, or by setting the Proxy property on the request object.

error 500 using webservices on IIS 6.0 WS 2003

I have developped a web service using c# and Asp.net and this works fine on my local machine where I use vista and IIS7.0. I call it via Jquery using this url
http://localhost/myWebservice/vote
But when I try it on the preproduction site, I receive an 500 error from the server telling me the /vote is not good. I still can access it directly in the browser when typing ?op=vote, but I have then an error saying the formatting of my xml is not right.
Am I missing something in the configuration of the IIS 6.0?
To use routes in IIS 6 you probably need a wildcard mapping in IIS; along the same lines as this (for ASP.NET MVC, but the same concept) - although to be honest, I'd expect a 4xx for a file not found.
500 typically indicates a more serious problem - for example, the app-pool identity isn't configured correctly and can't execute as a service. Check the event log on the server for messages.
As an aside; always try to develop on something as close to the actual hosting platform as you can. For example, I run a Win2003 server in a VM for hosting IIS6. This saves a lot of unexpected surprises when you come to deploy.

Categories