Can't access WCF service through browser - c#

I've been following this series of tutorials (https://msdn.microsoft.com/en-us/library/ms734712(v=vs.110).aspx) on getting started with WCF, and it's all been going well up until step 3 (https://msdn.microsoft.com/en-us/library/ms730935(v=vs.110).aspx), specifically up until the bottom, where it says "Open Internet Explorer and browse to the service's debug page at http://localhost:8000/GettingStarted/CalculatorService"
Basically, what this should be doing (I assume, I've never tried this before today) is opening some sort of web interface to this service, where I can edit it.
I've tried using both Chrome and IE, and neither of them can connect. I've tried lots of different IP addresses (localhost, 192.168.1.8, etc.) and they all give back the generic "This webpage is not available".
I'm using Visual Studio 2015 Preview (that MIGHT be the problem, but it shouldn't be...) run as administrator (I've tried running the .exe directly as well) on Windows 8.1, coding in C#. I'm not too experienced in networking things, so I might be missing something obvious... any ideas?

I found the problem. In the main library (the one with the contract and implementation), in App.config, I forgot to change the address that it binds to. Setting this to the desired one (http://localhost:8000/GettingStarted/CalculatorService) seems to work.

HTTP 400 is significant. It means bad request - eg your service isn't receiving input in a way it expected, but it is there. Please update your question. That sounds like a mistake in your WCF config. Try this... Open up a command prompt and run C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd.bat (Path for 2013, update as req'd). Then enter the command wcftestclient. It'll open up a gui that you can connect to the same url you're browsing to. It will attempt to talk to any WCF service listening there.

Related

Octopus Deploy and "Add Web Service Reference" / New-WebServiceProxy timeout

Working with Octopus Deploy, trying to deploy our SSRS reports packages. I used a community powershell script, which uses New-WebServiceProxy to create proxies for the report server web services so that it can upload reports etc.
Found that we have intermittent timeouts when calling New-WebServiceProxy. Sometimes it will come back immediately, sometimes will timeout 2 or 3 times in a row.
We checked all the usual things
making sure the site was running (not cold) when making the call etc.
different users with the right permissions
Creating a fresh SSRS isntance on a different server
No change.
As a final step in debugging, I created a console app in visual studio with the intention of adding the web service proxies there and replicating the functionaly of the powershell script (as a test).
Going to Add Service Reference --> Add Web Service Reference" in Visual Studio gives identical behaviour (after pasting in the URL and clicking the navigate/go button) as the New-WebServiceProxy call in powershell.
Sometimes this timed out or hung (requiring a VS restart). Sometimes it worked quickly.
Because of this, I'm wondering
Is there any known issue with these methods of creating web service proxies.
Has anyone else found intermittant timeouts when doing this? (I found mention of similar hangs / crahses in VS, but no answers).
Once the reference was added in Visual Studio, actual use of the proxy was quick and easy.
Is there a way to create a web service proxy in Powershell from a fixed definition (not from the URL) and still be able to change the target URL?
Is there a way to persist the proxy, or to use one generated in C#?
Any other suggestions gratefully received.
Update
Could this be user account related? If I run:
Invoke-WebRequest -URI https://ssrs-server.domain/ReportServer/reportservice2010.asmx?wsdl -UseDefaultCredential -UseBasicParsing -OutFile ReportService2010.wsdl
on my local machine, or on the deployment tenticle logged in as myself, it comes back near instantly. If I run it via Octopus deploy console, it takes randomly between 1 and 3 minutes to complete.
Any ideas on why this should take so long when running in that context?

IIS Express 'The specified port is in use' Visual Studio 2015

Apologies about the long message, but I thought I should let you know what I have already tried.
I've very recently started learning C# through Visual Studio and all was going OK until about three weeks ago. I clicked on the button with a green triangle which did the usual thing of launching the internet page, but the site never loads. I then noticed there was an ISS Express notification which brings up the following (can't figure out how to get my cropped screen shot on here):
'The Specified port is in use
Port 49665 is already being used by process "svchost.exe" (process ID "2112")
Recommendations
Try switching to port other than "49665" and higher than 1024
Stop the application that is using port "49665"'
I have managed to locate the svchost.exe on my computer and it is in the system 32 folder. There doesn't appear to be an option to stop it, and I am worried deleting it will break my operating system (I did click delete to see what happens and got an error saying I need permission from trusted installer to do this, but didn't go any further). When I open task manager and look through all tasks, including 'background tasks' and 'windows processes' and can't see it anywhere
I have tried to follow the advice in this discussion:
IIS Express Web Server Port Is In Use
But I cannot fully understand where the solution was- I don't think I have anything called ISS installed, however there is a Local ISS when I go to 'file', 'open website', which I found through the following:
Why and how to fix? IIS Express "The specified port is in use"
I did as the answer marked 21 (with the green tick) suggested and restarted my computer (as one of the comments suggested) however my problem persists. There is no longer anything under 'IIS Express Sites'
I have closed all browsers then tried, restarted and then tried, still no luck
The third answer (7) I really don’t know how to do this (I don’t know what solution they are referring to), so if this is a potential solution I’d be happy for further instructions
The answer marked with a 5 about netstat -aob helped me locate a task called ‘service host: local service (network restricted) (6)’. Trying to terminate this task brings up an error saying that by terminating this task Windows will become unusable- so I assume this is why I couldn’t delete the above. The final part of this answer about elevated access I don’t know what this means or how I would do this.
Closing visual studio and restarting as an administrator doesn’t fix the problem.
I only have Edge and Internet Explorer and I have ended these via task manager whenever I have tried to resolve this problem, but it persists
I tried the answer at the bottom, but was not able to locate the folder IISExpress, maybe this is part of the problem?
Any suggestions where I might be going wrong with the above, or any further advice on how to progress some of the things above, or any new ideas will be welcome.
Thanks for the suggestion Methodman. After much digging I found the solution you suggested here (change the port): How can i change IIS Express port for a site
The answer provided provides excellent instructions with a step by step guide on how to change the port
Just changed the port number until I got one that worked :)
Ed
It is an old post but just in case someone having the same issue recently; I tried many things including removing websites, running VS in administration mode. Nothing worked. Then I finally changed the port which finally worked. Right Click on project. Go to Web on the left menu. And change the port number at the end of the project url to whatever you want. I changed it to 50645.

Run c# code on client side or make a web session interactive?

I'm making an application on c# for signing PDFs. Its works perfectly on my visual studio web project, but when I publish it on my test server it throws me this Error
In this case I'm trying to execute the code that sign a pdf on the server and the error occurs specifically on the line:
System.Security.Cryptography.Pkcs.SignedCms.ComputeSignature()
It is supposed to throws a window on your desktop asking for your certificate (reading a smart Card) and then asking for your PIN just like this
Windows Security Window but I have the hunch that it's not possible because Its implies that the server have to have the possibility to interact with the client's desktop
Ok, now that I've explained all the enviroment that I'm facing, here are the solutions I've tried until now:
1) Trying to correct the Server Error above: I went in the server to IIS>application Pool>MyPage>Advanced Settings>Process Model>Load User Profile and selected True instead of False (Didn't Work)
2) Still trying to correct the Server Error I Went to Computer Management>Services and Application>Services and turned on the service "Interactive Service Detection" (Still not working and doesn't work even if I do the same on the client computer)
3)Finally, I guess that it's not possible to run the code on the server because the Error line above is a native calling of Windows Security so I thought: what if I try to run the code right from the client?. Like a c# applet equivalent or something, well... there are two ways for do that: ActiveX (old technology) and Silverlight (newer). The thing is that I just can't make a simple Silverlight program start on chrome, it does on firefox and IE but if doesn't work on chrome is a totally waste so my last option is to make it run with an ActiveX, and there is almost none useful information in the internet about that
If someone can tell me what to do, either to correct the error or to make my program run from the client side, I would be so grateful
You can't call the system's api from a Web client as this would break the sandbox. If you must use that system call, create a wrapper on the server that will handle the popup, although this would be a very "hacky" solution. You should really be asking why I am trying to use a Web client interface if I must use said native system call.

Browser opening, but failing to load localhost page--Selenium, MVC, C# .NET

I am starting to write tests for a project that is in its 8th agile sprint. I was brought on the team about one week ago.
Yesterday my Selenium tests were passing against the git master branch. I was accessing the http localhost address, opening it, running a test, and then closing the browser all from the Selenium code.
My team changed the access (somehow, don't quite understand) and the http localhost address changed. This was yesterday evening. Pulled the new code this morning from git.
I found the new address, and replaced it in my localhost constant. Ran the tests. Now the tests open the browser, no localhost info is entered into the url, test times out, test fails. All I changed was the localhost address.
When I just run start from the Visual Studio ribbon start button, the web app will open two windows in the browser (Firefox default). The team lead says that both windows are needed right now.
I am fairly new to Selenium (1 month and learning) and very new to .NET/Visual Studio/C# (day 4).
Researched the issue, only thing I have found that might make sense is creating an ASP.NET HTTP Module-- And I have read up on it, but don't know if it is THE solution.
If anybody has any other ideas, please let me know.
thx
a
EDIT : CODE
string URL = "http://localhost:54879/"; //unable to connect
....
driver.Navigate().GoToUrl(URL);
Had our local Microsoft guru look at what was happening. Tests run/console connects if I run after selecting start without debugging. I am v. new to Visual Studio, so I guess it was set up wrong in my tray and this makes it run properly.
In my case, the problem was that there was i needed to first run the programme without debuggen ( Debug > Start without Debugging).

visual studio development server automatically redirects to default port with machine ip

This is a weird issue I have been facing for a couple of days now. When I run my ASP.Net web app from visual studio 2010, it starts the dev server and opens IE. I can see the correct URL getting formed (ex: http://localhost:53990/index.aspx).
But then it redirects to "http://my-machine-ip". I can see the dev server process (webdev) in task manager. If I browse the above URL in a separate IE instance, manually, I still get the same behavior.
This problem comes in chrome as well, but works properly in Firefox.
Since it was working in FF, I ignored it, but now an increasing number of my colleagues have started facing the exact same issue. Tried searching for a solution on Google and stackoverflow, but couldn't find any.
Has anyone else faced a similar issue? Would be great if I can get any help/pointers with this issue. Please let me know if you need more details.
PS: I am coding in c#, not sure if it matters but thought I should specify it.
I have faced this issue and resolved by following steps:->
Open IE
Go to Internet Option ->Connections
Click on Lan Settings
Uncheck Automatic detect settings check box.
Clear all browser cache/history
Try and browse the site now. You should be able to view your site
Since Chrome uses IE settings, this solution should work for Chrome too.

Categories

Resources