How to resolve webservice issue in iis 8.5 - c#

I have a website set up in iis 7.0 on my local win 7 machine. Within this are several webservices - they all can be accessed fine, and I can test this access by going to a browser and checking at http://localhost/test/service.svc. This works fine. I'm not trying to recreate this environment on VM with win server 2012 R2, and iis 8.5. I've set up everything identically, except then navigating to the url above returns on the 1k tb inside the actual service.src as if I opened it in notepad. If I try to add a reference to this service in VS, I get a better error and one that is related to the mime type for svc. Here's an example.
Cannot add duplicate collection entry of type 'mimeMap' with unique key attribute 'file Extension' set to '.svc'.
Based on this issue, I then found a reference to needing to add something along the lines of to my config file which I do.
Now here's the interesting part. If I remove any references to the svc mime type in iis in both the server and the site, I receive a 404 not found error when trying to run a service. If I use the example above to add this with the config file, I receive a duplicate. If I take out the above example, and enter the mime type in either the server or the site, I then get a duplicate as well. I also found mention to this, and it seems there is some work around involving before the config inclusion as referenced above.
What's driving me the most crazy is that non of this is an issue on my local iis 7 machine. Does anyone have any suggestions, I'm floundering.

Related

Connection to a basic WebAPI fails

I am trying to test the possibility to convert all my WCF service to WebAPI but so far it's a mess. WCF is easy because you create a default project and add 1 or 2 sample method that return anything then add as a service by using the http address and it works out of the box.
On WebAPI you add connected service and type the address and it throw errors so obviously out of the box it has errors and is missing stuff to actually work.
My question is what is missing to WebAPI made with .NET6 to be able to be connected to ?
Following Microsoft example what i should do is to run the service obviously. Then use the path of the json file generated by swagger and input that in the URL of the connected services, give it a namespace and a classname and your good to go.
Step 1 : Running the service
This works i can call the basic 3 method i made for test purpose that return string, List<string> and List<List<string>> and i can execute the "tryout" button and they output everything that it needs
Step 2 : Copy the json file path provided by Swagger
I assumed that this url is good by default. I can click it and i see the definition which seems good.
Step 3 : Create and empty console app and add the connected service
When adding the connected service i pick OpenAPI as it's the only option anyway.
Then it asks for File or URL that i put my value form the service that is running. In this case this is : https://localhost:44341/swagger/v1/swagger.json. I then choose the namespace of WebTest1 and classname of WebTest2 as i dont care and click next
Step 4 : Configuration progress
This is where i have the error which is where i see that the service that can actually run cannot be connected to
Checking project for required NuGet packges... Downloading service
reference from https://localhost:44341/... ErrorFailed adding service
reference(s). Failed to download metadata file from :
https://localhost:44341/.
I finally figured out the temporary fix. I was also able to copy this project over to a colleague and the issue is the same. The problem lies into Visual Studio defaulting for some reason on the debug option of IIS Express which does properly run the service when you press F5 and your browser open normally and you can test things out. The problem is that when you project runs under IIS (actually configured like it would be the real deal) or IIS Express (the only IIS option in the debug setting) you cannot from another application connect to that service.
However if you switch the debug option to the project name and run your WebApi with that instead it also works as expected from the browser that it open but you now can actually add that service from another application without any error.
Personally i have a third option which is WSL which i "guess" is the linux sub system i can't tell as this crash when i try to start and there is no help for the UI of Visual Studio to help understand these menu options.
Now i still have a problem to attach to one running in a real IIS which is probably linked to the same reason why IIS Express debug doesn't work. So i now know that the base code works and now it's an issue of finding why the default doesn't let other application consume from IIS / IIS Express.
For reference purpose this is the debug menu in question where the IIS Express option is not working but selecting the project name like pointed out on the picture actually works.

ASP.NET website deploys but only I can see

I have a prototype .net web site that is on Windows 10, created using C#. I am using IIS on the same machine to deploy from Visual Studio 2017. It uses SQL Server for back-end data. The site only runs on intranet.
It deploys ok, I can see all the pages, from all three of my machines. But others cannot see anything. They get a run-time error, that does not say anything specific.
My machine was re-imaged and hence the need to redo this.
I looked at IIS log and it does not have any info. What else I can look into?
In web.config, turn off custom error mode to see detailed error message on the client:
How to set web.config file to show full error message
If it works locally and not remotely, it's likely a permissions error (accessing a resource that the client doesn't have access to), or maybe a pathing issue (you are referring somewhere to something by disk or UNC instead of URL, or to a domain that only makes sense to you, like localhost).

Website not working after migration from one EC2 server to another

I'm wondering if any of you can shed some light on a problem I'm having.
I had a website located on an Amazon EC2 instance, it was working with no problems however the person who set it up located it the wrong region. As a result I've set up a new EC2 instance and zipped up the website directory.
I copied it across to the new instance and unzipped it.
Then I set up the website in IIS, it has it's own username so it doesn't run under IUSR. This use has full permissions to run the website and other than location, the setup is identical to that on the previous server.
However, when I go to adjust the connection string through IIS I get a message:
There was an error while performing this operation.
Details
Filename: \?{path to web config here}
Error:
I've not seen anything like this. I can open the web config in notepad++ and make changes with no issue. But the site reports the web config as malformed. Even using the exact web config from the working server this same message appears.
I've tried re-compacting the site on the working server and transferring again with exactly the same results.
Anyone got some advice on what I could try?
I'd be willing to bet that an extra module that you had installed on the old instance is not available on the new instance; I had a similar problem when I was using ther url-rewrite module of IIS on one instance, and moved the site to another instance that did not have that module installed and got a very similar (if not identical) error message - that would explain why the config was valid on one server, but not on the other.
You need to make sure all of the 'extra' options that were turned on in the old instance are available on the new instance, and I'd start by checking the rewrite module.

CS0103: The name 'xxxx' does not exist. This randomly occurs

I have researched this quite a bit and while I can find a number of articles on the general issue and the code, unfortunately none quite like what we have.
Environment: We have 2 web servers running Windows 2012 and IIS 8. All running .net 2-4.5
Web Server 1: This is our main server that runs our main websites and web applications
Web Server 2: This runs our client websites
Code: Both sets of code are uncompiled. Both the shared code and the client websites are .NET 4 sites.
Scenario
On Web1 we have a set of website code that is shared amongst a number of client websites. On Web2 the client site is set up in IIS and a sub directory of the App_code is a virtual directory pointing to a folder in the shared code on web1. We also have another virtual folder that points to the Web1 code as well. We have over 100 websites running in this fashion for over a couple of months.
Recently a couple of our clients have contacted us to say that they are receiving an error when browsing to parts of their website that are served by these virtual directories. The file that it references in the error message is in a modules folder in the virtual directory. it is a .cs file.
It only seems to be one website at a time and if we make a change that forces IIS to 'recompile' the site (meaning that we make a slight change to the web.config, save it and then change it back and save again), the error disappears and the web site starts working correctly. When we check other sites that are in the exact same setup as the one failing, we do not get any errors and they work correctly.
We are whits end as the issue seems to be completely random. This issue has only started occurring in the last week or at least this is the first we have seen of it.
We are at the point where we believe that it might be an IIS 8 issue and something that might be occurring when it is trying to recompile a client web site but due to the randomness and the 'easy fix' it is difficult to troubleshoot or even know where to go looking for the issue.
Any help would be much appreciated.
Thanks
Don
What is the error you're having? Based on what you said, the behavior is random and points on a C# file, not much can be said and only guesses could be make...

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