Web Service error - Status 404 not found - asp.net

I have created a web service in Visual Studio 2015 (web api) that listens out for requests via a barcode scanner. The barcode scanner links to a database that provides information such as stock quantities etc, but this is just for background information. The web service is currently installed on my local machine and works perfectly, returning the correct values and posts data to a database.
I attempted to install the web service onto a server, copying over similar settings in IIS (only have basic knowledge using this), such as the bindings and ensuring the permissions were set up correctly. However when running the web service I recieved a "404 not found error and 401 unauthorized". After that, I installed Visual Studio 2015 onto the server to ensure it wasn't a build or publish error...same problem.
Below are some of the 'fixes' I have tried to help narrow down the potential problem.
Ensured the correct version of .Net, 4.0, is installed on the server.
IIS Manager - Authentication: Annoymous Authentication set to enabled.
IIS Manager - Directly browsing: set to enabled.
Set the correct permissions using 'Edit Permissions', granted full control to 'Everyone'
This is my first time creating a web service so up until now I have been using tutorials and making it up as I go along. I think it could be to do with the application pools set up? But because the solution works on my local machine and not the server has me extremely confused. Thanks in advance.

Related

Silverlight 5.1 app breaks when moved to new server

I inherited a Silverlight 5.1 asp.net application which has been running successfully on a Windows 2008 R2 server running IIS 7 for many years. I've been tasked with moving this application to a Windows Server 2016 Standard machine with IIS 10.
I installed Silverlight 5.1 (client) and the Silverlight 5.0 sdk on the Windows 2016 machine but otherwise made no changes. The machine has Framework 4.7.2. Several other asp.net applications are hosted on this server, but this is the first Silverlight application.
I tried simply copying the old application to the new server, and also rebuilding and publishing the application from the source code to the new server. I've tried running under both http and https. In all cases I get the error as described below.
When I navigate to the application using IE 11 with the Silverlight plugin installed I get a popup, "Load operation failed for query 'GetUser'. [HttpWebRequest_WebException_remoteServer] Arguments: NotFound..." and etc.
Nothing is logged that can be seen in the Windows event viewer.
Using Fiddler I can see that the browser is making this call first and getting a 404 Not Found error:
GET http://xxx.xxx.xxx.xxx/ClientBin/PMSys-Client-Web-AuthenticationService.svc/binary/GetUser HTTP/1.1
Referer: http://xxx.xxx.xxx.xxx/ClientBin/PMSys.Client.xap
Looking in the source code I see there is a class named "AuthenticationService", which derives from System.ServiceModel.DomainServices.Server.ApplicationServices.AuthenticationBase, which in turn has a GetUser method. I can also see the file PMSys.Client.xap in my "ClientBin" folder. I assume some Silverlight magic inside PMSys.Client.xap creates the path http://xxx.xxx.xxx.xxx/ClientBin/PMSys-Client-Web-AuthenticationService.svc/binary/GetUser.
Using the same instance of IE 11 and Fiddler, but calling the old, successful machine, I notice that it gets Silverlight.js first, and then makes the same call to ...binary/GetUser. On the new, failing machine there is no call to get Silverlight.js. I assume this is a clue.
I can run this application in debug mode in Visual Studio 2017 on my local machine. The App.xaml.cs file contains a method "Application_Startup". This method calls WebContext.Current.Authentication.LoadUser(), which in turn calls this bit of code:
public EntityQuery<User> GetUserQuery()
{
this.ValidateMethod("GetUserQuery", null);
return base.CreateQuery<User>("GetUser", null, false, false);
}
This works on my local machine. I assume this is the "GetUser" call that is failing when I visit the application on my 2016 server; my understanding of Silverlight is that this "GetUser" call is made by the Silverlight runtime in the browser to the server.
My question is, what am I missing in my setup that is causing the 404 error? Why does the old, successful application load Silverlight.js, but the new, failing application does not?
This seems to be a server-side problem. If I paste the path http://xxx.xxx.xxx.xxx/ClientBin/PMSys-Client-Web-AuthenticationService.svc/binary/GetUser into a browser address bar I get a 404 error when I hit the new, failing site. For some reason IIS is simply not serving up Silverlight stuff. But if I pass that same path to my old, working application I get the usual browser prompt, "what do you want to use to open this file," and the result of the call streams down to me.
On both the new (failing) and old (working) sites, if I paste the path of the referer, http://xxx.xxx.xxx.xxx/ClientBin/PMSys.Client.xap, into the browser address bar I get the usual prompt, "what do you want to use to open this file."
I've checked every IIS setting comparing the old site to the new site and they are in agreement, including "Full Trust" and the existence of the .xap, .xbap and .xaml mime types.
Does something else need to be installed on my server in addition to Silverlight 5.1 and the 5.0 SDK?
I've seen several posts about installing RIA Services, but this appears to be a Silverlight 4 issue. RIA services are not installed on the old, Windows 2008 machine and the application is running successfully there. From what I've intuited RIA services need to be installed on the development machine in order to reference the "System.ServiceModel.DomainServices" libraries, but these become part of the deployment in Silverlight 5, so there is no need to install RIA services on the web server. I have confirmed that these libraries are in the deployment.
The answer is to enable HTTP Activation for the WCF Services under the Add Roles and Features Wizard, see this SO answer

deploying asp.net core 2.1 web application on window hosting receiving 403

I have deployed my newly created web app developed in Asp.net core 2.1 on a windows based shared plesk hosting.
When i tried to browse the site, it give me this error
403 - Forbidden: Access is denied.
You do not have permission to view this directory or page using the credentials that you supplied.
I have searched it on google but all the help is coming for .net framework not for the .net core framework. Existing solution has suggested me to put this code in web config
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
but in .net core 2.1 there is no web.config in the project..
Bottom line issue is still there, don't know what to do.
First of all ensure that the your shared hosting provider support .NET Core hosting as it requires .NETCore Hosting Bundle installed and .NET CLR Version set to No Managed Code
Next publish your ASP.NET Core web app which will generate web.config file and then upload the published files on the server.
You may need to look at hosting's website or get in contact with them to determine whether they support .NET Core, at what runtime version and what needs to be done to have it set up for a website. They may need to do it manually and you may need to downgrade to their version.
The simplest way to handle this with shared hostings is to publish fresh template that works locally, copy it over to hosting (or use Web Deploy to do this directly from Visual Studio) and if it errors, write a ticket that your .NET Core site isn't working and it's up to them to install and set up everything that is necessary.
If they can't get it working, then you won't be able to either. Nothing else you can do, but to change hosting provider.
Literally just stumbled on this question after finding a resolution to the exact same problem.
My scenario is:
I was trying to move hosting providers - website already live, running from old host's webspace.
New host was a shared windows-based web hosting provider, running Plesk.
I was therefore trying to publish my .Net Core 2.0 project to my new host.
...and I kept getting a "403 - Forbidden Access" error.
Here's what I found, which I think might have been part of the problem that the OP faced.
Even though I had published the website to the remote server correctly, the 403 error kept coming until the new host's technical support pointed me to one of their knowledgebase posts, which exactly described my scenario and the issues I had, along with how to overcome them.
Essentially, I didn't have my domain name's DNS settings configured yet (as it was still in use, pointing to my previous hosting provider's webspace) and as such, the DNS are getting 'confused'.
The short-term workaround was to add a temporary entry to my hosts file on my PC, which directed the traffic for my website to the IP address of the NEW web hosting provider. (Once full go-live, these are deleted).
Something like this:
123.123.123.123 mywebsite.com
This allowed me (on my PC) to bypass the DNS settings on my domain name, and to reference the web content on the new web host's webspace, to continue setting-up and configuring the website, prior to full migration
Here's the link to their knowledgebase article, which I'd have never of thought of, until they mentioned it. (And then it made perfect sense!!)

The resource cannot be found in IIS server 2012

I am trying to move a web site, with several web applications over to a new server running server 2012. The application was written in .net 3.5. I have been struggling through some issues but am now stuck on The resource cannot be found
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: Any web app I tried URLs
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1087.0
I have tried running the app pool as .net 2.0. Enabled 32-bit applications. Set the security of the entire inetpub folder to allow all users full permission, still I am stuck. I also tried setting the application pool back to the default user. I get a 500 error then. The user I am running the app pool under is in the IIS_* group. The application pool is setup identical to that of the old server. The file does exist at the url I am trying and it is named correctly as I have tried it on several different applications within the site. It appears this is .net to blame more than IIS. Due to enterprise security I can't get remote debugging enabled on the server. Is there any logging that I can check to see why the page won't load?

Problems publishing site to localhost on windows 2008 rs server

I must preface this post by saying that I am not an experienced developer, I am in the process of learning through trial and error and a lot of google searches so detailed (step-by-step) feedback would be greatly appreciated. I created a website, which does not use a database, using visual studio 2015 and I am attempting to host it locally on a Windows 2008 R2 server.
I installed IIS and loaded the asp.net v4.0 framework. The site works fine, produces no errors when I test it and works after being published only if the visual studio is still running.
However, when I close the Visual studio and open my browser window to http://localhost:50044 (which is the URL listed in properties menu in VS), I also tried using port :80 and nothing. When trying to add Web Site via the IIS management utility I receive the following authentication error: ”Cannot verify access path (C:\Inetpub\wwwroot).”
I checked the permissions and windows authentication is enabled with read access, and all other permissions seem to be correct. I am at a loss, I'm sure it is probably something simple that I am missing due to my lack of knowledge and experience. Any help would be appreciated.
It's sounds like you are running on IIS express which in your case stops running when you close visual studio. Normal process is create a new website in IIS and point to the folder where your web.config is. You can then hack your host file (C:\Windows\System32\drivers\etc) so DNS works. Add an entry like "127.0.0.1 mytestwebsite.com". I hope that helps
So I figured out part of what was happening. I didn't realize that visual studio has built in IIS and was using that by default.
I ran VS as an admin, created a new project, then attempted to create a virtual directory thru VS under the project/properties/web tab. I selected local IIS and entered http://localhost/boc and it returns an error: unable to create vd. Web server http://localhost... Could not be found.
I then went in to the IIS manager and set up a virtual directory with no issues. However, when I attempt to reference it thru VS I again receive an error message.
Any ideas?

Web Deployment Issue Using Windows Azure Accelerator For WebRoles

I am new to Azure Accelerator for web roles I have performed each step on the guidance from the net but I am getting an error when I try to deploy my website.Everything is rechecked by me WMSvc is running and is set to auto and username and password is correct but I dont understand where is the problem.
Error 1 Web deployment task failed.(Remote agent (URL http://2f96c9ab6cda4281bcf25a899d66955d.cloudapp.net/MSDEPLOYAGENTSERVICE) could not be contacted. Make sure the remote agent service is installed and started on the target computer.) Make sure the site name, user name, and password are correct. If the issue is not resolved, please contact your local or server administrator. Error details: Remote agent (URL http://2f96c9ab6cda4281bcf25a899d66955d.cloudapp.net/MSDEPLOYAGENTSERVICE) could not be contacted. Make sure the remote agent service is installed and started on the target computer. An unsupported response was received. The response header 'MSDeploy.Response' was '' but 'v1' was expected. The remote server returned an error: (401) Unauthorized. 0 0 QuickMVCdep
Please help me to find the solution so that I can deliver my project to Client.
I have run into the same issue.
It appears that the Publish action from the VS Azure tools will set up the MSDeploy correctly as part of the deployment process, but creating a package from VS and then upgrading the server using the Azure portal will not. Which is a bummer since the VS Publish action deletes the deployment and then recreates it, which will reassign your VIP address.
I haven't been able to pinpoint the difference, but one thing I've noticed is that if you do a Publish from VS, MS Web Deploy 2.0 will be installed for you, whereas I don't believe it is when you run an Upgrade. That said, I've never managed to manually install/configure the right bits on an Azure server to enable MSDeploy (I suspect that there is some LB/firewall configuration that happens outside of the host to allow traffic to 8172).
All in all, MSDeploy is useful enough during development that I prefer that pain (which requires me to change my A record in my DNS every time I do a major upgrade) over the alternative (Upgrade using the portal and lose the ability to use MSDeploy).
I would love to learn of a solution where we can have our cake and eat it too (an upgrade package that allows MSDeploy'ing a web role).

Resources