404 error when accessing WCF Rest service hosted in ASP.net on Windows Server 2008 - asp.net

I have a WCF Rest Server hosted in an ASP.net Application. It was set up using the simple RouteTable setup in global.asax. ON my development machine with IIS 7, it works perfectly, but when I deployed to A windows Server 2008 machine with similar IIS settings, it does not work, I get a 404 error when my ajax methods tries to access the service. I was wondering if WCF is able to be hosted like I have on my development machine on an actual production server? If so what must I do to get it to work.

turns out from careful googling it turned out to be a missing attribute on system.webserver modules section: runAllManagedModulesForAllRequests="true"
Source:
http://www.west-wind.com/weblog/posts/2011/Mar/27/ASPNET-Routing-not-working-on-IIS-70

In my case, it was even more simple!
The symptom was that all POST requests returned 404s.
I'd only just enabled IIS (via Programs and Features -> Turn Windows features on and off) on a new Dev machine that already had Visual Studio fully installed.
I had to enable .NET 4.5 for IIS (via C:\\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i) and then all was well.
It's confusing, because I had already set the IIS App Pool to run under .NET Framework v4.0.30319. There was no warning that I had to separately run regiis.

Related

WCF Service Migrated to IIS 10 - Consistent 503

A computer hosting a WCF service at my work was swapped out from a Windows 7 instance running IIS 7 to a Windows 10 instance running IIS 10.
The WCF service is a third party service that allows remote control of the robotic system the computer is connected to, so I have no access to the source code.
I've tried using MS Deploy to migrate, I've tried perfectly replicating every single setting in IIS and installing all the necessary .Net Framework versions, and I've completely re installed .Net Framework twice.
No matter what I do it always results in a 503 - Service Unavailable. The logs in HTTPERR simply state "N/A" for each failed request to the svc file.
Yes, I've added the svc Mime type and handler.
Also Server Manager has been no help, as it's Windows 10 and not actually a server.
EDIT:
Here are the settings I've copied over:
Application pool for default site uses .Net CLR 4.0, with Application Identity and 32-bit applications disabled.
Application pool for the WCF service uses .Net CLR 4.0, with Network Application as its identity and with 32-bit applications enabled.
It works perfectly fine on the old server, so I'm still at a loss as to why it doesn't work on the new one.
Thanks to Travis Acton for the suggestion to check netsh http show urlacl!
I decided to run the delete command for the port despite it not being shown, and it indicated that the port reservation was successfully deleted. For some reason it was unlisted by netsh.
So now it's all working fine! Thanks so much for the help!

RESTFul service works in IIS Express / VS2013 but not on IIS Server

I developed a RESTFul Web Service in VS 2013 and it works fine locally on IIS Express.
I publish to a package which I transfer to another PC and using IIS Manager I import the zip file as part of the Default Web Site.
Loading the url in a browser always leads to a "Server Error in Application" HTTP error 404 (or other 40x error).
I've tried to different implementations, one with svc file and one without. Also setting target framework in web.config = 4.0 and setting the Default Application pool to .Net V4.0
How do I get my service (which runs fine from Visual Studio) to work in IIS?
I found an update from Microsoft to enable IIS 7.5 handlers to handle requests whose URLs do not end with a period
My Windows 7 would not install this update so I ran Windows update to apply many updates. Although none looked directly related to extensionless urls it did the trick.
I imported my application using IIS Manager as before and it works fine!

Cannot connect ASP.NET development server (VS2010) via IP address

Visual Studio 2010 / ASP.NET project / ASP.NET Development server
I can run and debug my VS2010 ASP.NET project from my development computer (where VS2010 runs). URL: http://localhost:port/MyApp.htm works fine.
Since I want to test the application from an IPad as well, I need to call the application with its IP address such as http://192.168.0.132:port/MyApp.htm
To my surprise this does not work, neither from the IPad, nor from the dev. computer itself. It is not a matter of connectivity, the address is correct / ping is possible.
(Note that I have no IIS installed on this machine, actually the ASP.NET application is plain HTML+JS, I use VS2010 just for debugging.)
Any workaround for this?
The Visual Studio Development Server will only serve pages to the local machine:
From Web Servers in Visual Web Developer:
If you cannot or do not want to use IIS as your Web server, you can
still test your ASP.NET pages by using the ASP.NET Development Server.
The ASP.NET Development Server, which is included with Visual Web
Developer, is a Web server that runs locally on Windows operating
systems, including Windows XP Home Edition. It is specifically built
to serve, or run, ASP.NET Web pages under the local host scenario
(browsing from the same computer as the Web server). In other words,
the ASP.NET Development Server will serve pages to browser requests on
the local computer. It will not serve pages to another computer.
Additionally, it will not serve files that are outside of the
application scope. The ASP.NET Development Server provides an
efficient way to test pages locally before you publish the pages to a
production server running IIS.
The ASP.NET Development Server only
accepts authenticated requests on the local computer. This requires
that the server can support NTLM or Basic authentication.
If you wish to test pages remotely you will need to use IIS or IIS Express.
I ran into this same problem and found a great solution. You can use SPI Port Forwarder (or a similar tool) to forward outside requests to the VS development web server. It works great and you can turn it on and off as needed.
Check out the info here:
Accessing the Visual Studio ASP.NET Development Server from iPhone & iPad
http://opensource.oxyva.nl/simple-development-proxy seems to work around Visual Studio Express 2012 for Web not allowing connections from other devices like iPhone, iPad etc. which result in "HTTP Error 400: Bad Request - Invalid Hostname"
There seems to be another solution as described in: visual web developer Web service on debug HTTP/1.1 400 Bad Request
You need to set up a WebSite in IIS, and deploy solution to virtual directory for the application to be accessible through an IP address outside of localhost(127.0.0.1)

What is to prevent me from using IIS Express exclusively on my development box?

I have only read a bit about IIS Express, and am in the process of downloading and installing it now. It seems like i should be able to uninstall IIS proper and just make use of IIS Express when developing/debugging webserver-based technologies in visual studio (2010 SP1).
Is this a sane conclusion?
What development scenarios might not play well with IIS Express?
Are there cases wherein IIS proper would absolutely still be needed?
My use of IIS in the past has been for ASP.NET MVC cases, a few web service debugging sessions, etc. Obviously IIS proper is still needed for actually hosting the resulting solutions, but can i realistically "free up resources" and just use IIS Express on demand?
To my knowledge some known issues with IIS Express:
Only http/https protocols are supported
There is limited UI support (through Visual Studio and WebMatrix) to configure IIS Express. But you can configure it manually by editing applicationhost.config.
IIS Express runs as current logged on user, so you may run into issues like http://forums.iis.net/t/1175734.aspx
It will be slow because by default failed request tracing and console tracing are enabled (failed request tracing can be disabled by editing applicationhost.config file)
Kernel mode caching is not supported

Why is IIS not serving aspx pages?

I'm deploying an ASP.NET application to Windows Server 2003 under IIS
IIS is serving html pages fine but I get a page not found when I try and serve IIS pages
You may need to "register" IIS for ASP.NET applications. As an administrator, run the command "%systemroot%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis -i". In addition, you may need to convert your web site to an application through the IIS management console.
By default, IIS has ASP support disabled in IIS6.
A server running a member of the Microsoft® Windows® Server 2003 family supports application server functionality, with Microsoft ASP.NET as an option that you can enable when configuring the application server role. To deploy ASP.NET Web applications to a production server, you must be sure to enable the ASP.NET and Internet Information Services (IIS) roles on the production server before you distribute the application.
See here for instructions to enable it:
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/9fc367dd-5830-4ba3-a3c9-f84aa08edffa.mspx?mfr=true
Other possible reason could be Web Service Extensions, where ASP.NET version could have been disabled. My other post here explains steps to solve this.
Make sure the right .NET framework is installed properly
Make sure the ASP.NET extension is enabled
Under website properties, ASP.NET tab, make sure the right version is set.
After having this same issue and trying all of the above without any luck. We reinstalled SP2 for Windows 2003 and this resolved our issue. I too have seen this problem resolved a few times with the other answers. Most of the time just reinstalling .Net 2.0 resolves the issue but not this time.
For future reference, this could also be the issue:
IIS on a Windows Server 64-bit can only to run in either 32 or 64 bit mode.
In short you need to:
1) run adsutil.vbs to enable 32 bit asp.net apps on win 64
2) re-register IIS calling aspnet_regiis.exe
3) re-open IIS Manager, go into Web service extension list and ensure ASP.Net version {2/4.xxx} (32-bit) is set to Allowed
(You might need to do Steps 2 and 3 for both Framework 2.0 and 4.0 if you want to run asp.net apps on both versions)
Full details are in the following link: http://support.microsoft.com/kb/894435
Another future reference in case this is helpful to anyone who used a similar path to mine.
My back end for the ASP.NET app was MySql not Sql Server, which for me meant having a mysql connector, the reason my IIS was not serving the .aspx file is because on my development environment I was using a different version of the MySql connector than the one installed on my production environment, I updated the MySql connector on the production server to match the version Im using on the development environment and it worked great.

Resources