WPF Desktop and web service in same solution - c#

I am revising .NET and web services and attempting to test calling the web service I created with a WPF desktop application. The web service builds and runs fine and when I start without debugging in VS Community 2017 it works as expected and I can see the web service end points in the browser along with the WSDL. But when I attempt to add a WPF desktop application and start without debugging to the browser does NOT have the .asmx file in the URL anymore and states -
HTTP Error 403.14 Forbidden
the web server is configured to not list the contents of this directory
I have googled this error and tried several of the suggested fixes but none of them have resolved the issue. Can this be done at all or do I have to publish the web service to IIS Express on its own and have the WPF desktop application on its own? Its just that it would be very useful to have a desktop application within the same solution to code and test

Related

How to fix the 500 internal server error when deploying a web application to an ASP.NET framework VM on google cloud?

I am trying to deploy a simple ASP.NET web application over the Internet, using the google cloud platform. I followed the tutorial on this page : https://cloud.google.com/dotnet/docs/getting-started/hello-world (I uploaded a slightly more complex app though). So basically everything went well from the creation of the ASP.NET framework virtual machine to the deployment from my computer to the VM since I've been able to reach for the web app home page through the VM IP address.
Starting Web deployment task from source: manifest(C:\Users...\obj\Release\netcoreapp2.2\PubTmp\myApp.SourceManifest.xml) to Destination: auto().
Updating file (Default Web Site\MyApp.deps.json).
Updating file (Default Web Site\MyApp.runtimeconfig.json).
Updating file (Default Web Site\web.config).
Successfully executed Web deployment task.
Problem is that the home page won't display as it did when I would deploy it locally (with IIS express) but rather throw an
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
I found some interesting subjects raising the same issue :
Deploying website: 500 - Internal server error : suggests to enable detailed errors and/or to change a few lines in the web.config file but I do not have a web.config file at my side of the process in my project (only a Startup.cs which does some of the work) and I cannot manipulate the one in the google virtual machine.
I noticed that before uploading the web app to the VM, the output displayed errors similar to these : https://github.com/dotnet/sdk/issues/1897 (message NETSDK1041) so I thought that the discrepancies between referenced/platform assemblies might be the origin of these errors but then, why wouldn't they impact the local deployment of the web-app too ?
I would like my web application to run on google cloud's VM (based on the generic Google Compute Engine ASP.NET framework), the web app is 'correctly' deployed to the host VM but raises a wild 500 - internal error. Anybody has any idea as to how I could at least identify the source of this error ? (Helping me find the web.config would also help greatly, I understand that everybody has this file somewhere, but I can't find it and don't have a clue on its whereabouts because I just used a random template MVC application on Visual Studio Community 2017 which did all the configuration work

Web-Service not working without reference update

I got a WPF project that is using ASMX web-service to connect to database. The problem is I can't connect to the web-service without updating web-service reference. Even if I've updated reference and then built the solution I can't connent to the web-service after closing visual-studio.
In this situation, it appears VS is hosting your web service via Cassini or IIS Express. That port number is a setting that can be changed in the project's configuration. When you close visual studio you are closing the web application host. If you are attempting to test your service locally, without VS hosting, then you will need to configure a new web application to run on a local instance of IIS pointing to the output directory of the service. You can still bind inside of your solution to the services' project reference, you just don't need VS running to access it locally.

Hosting WCF service on IIS7.5, receiving 404.0 error

I just received a new development laptop and now I can't get one of my WCF services running on the new laptop.
Windows 7 Enterprise
IIS 7.5.7600.16385
Windows Features Installed:
Internet Information Services
Web Management Tools
IIS 6 Management Compatibility
IIS Management Console
IIS Management Scripts and Tools
IIS Management Service
World Wide Web Services
Application Development Features (all sub-features)
Common HTTP Features
Default Document
Directory Browsing
HTTP Errors
HTTP Redirection
Static Content (all sub-features)
Health and Diagnostics (all sub-features)
Performance Features (all sub-features)
Security (all sub-features)
Internet Information Services Hostable Web Core
Microsoft .NET Framework 3.5.1 (all sub-features)
Windows Process Activation Service (all sub-features)
I dropped a simple "Hello World!" index.html file at the root of the WCF services application. I am able to serve that .html file. My services are under a sub-directory named "Hosts". I also dropped a simple index.html file under that sub-directory - I am able to serve that file as well. I cannot serve any of my .svc files though.
http://localhost/mywcfapplication/Hosts/IncidentService.svc
Anonymous Authentication -- "Application pool identity" is selected
The services are running in their own application pool. About the app pool:
.NET Framework Version: v2.0
Enable 32-bit applications: false
Managed Pipeline Mode: Classic
Identity: ApplicationPoolIdentity
I recently set these services up on a new Windows Server 2012 R2 web server in our test environment (old test server was decommissioned). On the server I had to give the app pool user permission to the directory in the file system (IIS_IUSRS\apppoolname), but my laptop doesn't seem to like this.
I'm receiving a 404.0 error when I attempt to browse to any of my .svc files under this application. IIS tells me the most likely causes are: •The directory or file specified does not exist on the Web server.
•The URL contains a typographical error.
•A custom filter or module, such as URLScan, restricts access to the file.
I have checked and re-checked the URL, and I can serve the .html files. I verified that the .svc files do exist. I'm at a loss. What have I overlooked?
Research:
IIS7.5 WCF Service - HTTP Error 401.3 (Even after adding IIS_IUSRS)
Hosting WCF service on IIS7.5
Windows 7 IIS7.5 and asp application Error HTTP 404.0 - Not Found
UPDATES:
6/8/15 - I added IIS AppPool\AppPoolName to the IIS_IUSRS group. No change.
6/9/15 -
I ran servicemodelreg -i. No change.
https://msdn.microsoft.com/en-us/library/ms752252(v=vs.90).aspx
Because I'm getting desperate, I ran aspnet_regiis –i –enable and then "%WINDIR%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -r
I also followed the steps listed "to verify that the svc file type is mapped correctly in IIS7.0"
HTTP 404 when accessing .svc file in IIS -- "We had a similar problem, and the SVC handler was already correctly installed. Our problem was the ExtensionlessUrl handler processing requests before they reached the SVC handler. To check this - in Handler Mappings in IIS Manager at the web server level, view the list of handlers in order (it's an option on the right-hand side). If the various ExtensionlessUrl handlers appear above the SVC handlers, then repeatedly move them down until they're at the bottom."
I verified that the extensionless handlers were at the bottom.
At the advice from yet another forum post I added a MIME type for .svc. No change.
6/15/2015 -
- Log file: u_ex150615.log
I got exactly the same issue and finally found a way through it.
The point is that WCF need a integrated pipeline to work properly. In Windows 7's IIS 7.7 I solved the problem by setting the Application Pool to use Integrated Pipeline mode (it was in Classic Mode). But Windows Server 2003's IIS 6 doesn't work with integrated pipeline, so Microsoft .Net uses Web Services Extensions, you could check at IIS 6, right above Web Sites. Ensure that the desired .Net version is allowed in Web Services Extensions. Than you need to register the Service Model extension.
Here´s what I did:
%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -i
%windir%\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe -i

Starting a ASP.NET restful webservice on IIS

I have developed a restful web service using ASP.NET, and while using the Visual Studio environment, it worked like a charm with IIS Express. The service itself is a complementary feature and will have to run on every machine on which our product is installed.
I have therefore created a new directory webservice, which holds the web.config and the Global.asax file, as well as a directory bin, which holds the RestulWebservice.dll file.
I then have setup a new web page on the IIS, rooting at C:\inetpub\wwwroot. The web page itself is hosting a web application, based in C:\inetpub\wwwroot\RestfulWebservice (which holds the files described above).
However, if I startup the IIS and visit http://localhost:80/RestfulWebservice, all I am getting is an error 403.14, stating that I may not inspect the contents of this folder unless I allow IIS to do so. If I choose to allow this, I am simply presented with the contents of the folder, not the service itself.
If I try to access a resource of the restful web service directly (i.e. http://localhost:80/RestfulWebservice/Home, I get a direct 404.0 error, telling me that the resource does not exist)
What am I doing wrong here, it can impossibly be this hard to get a compiled library ASP.NET web service to run on the IIS, it works like a charm on IIS express.
c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i

How to debug calls to ASP.NET web api in Visual Studio [duplicate]

I built a Web API service that's hosted locally on my machine in IIS. I have an iOS app that I'm running via XCode that makes the call to the web service. The connectivity is there, and works. The iOS app successfully makes the connection to my published web service.
The problem is my web service is returning a non descriptive error to the client (iOS), so what I need to be able to do is step through the web service code while running my iOS app.
So, in summary:
I run an iOS app via my MacBook, and it connects to my .NET Web API service.
My Web API service is published to my local IIS, and is returning an error back to the client.
Breakpoints aren't being hit in Visual Studio - do I need to attach my Visual Studio debugger to a specific process? I've tried running my web service in debug mode while running my iOS app, to no avail.
How can I step through my web service code when running the client app (iOS) that accesses the web service?
Attach to process - http://msdn.microsoft.com/en-us/library/vstudio/3s68z0b3.aspx
Make sure "Show processes from all users" is checked, and pick w3wp.exe
You may need to hit the service once first to make sure its started.
To debug an app that's hosted by IIS, you want to attach to process (in Visual Studio it's Tools->Attach to Process or Ctrl+Alt+P) and pick w3wp.exe from the list (you might have to check a few boxes for the process to show up).
Another option is to use our free VS Extension called Conveyor
https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyoti
With it you open up IIS Express to remote connections on your network (or even the web through tunnelling).
Once you've done that you can debug the project directly from VS and connect to the Conveyor port number (or domain name via tunnelling) and debug as you would locally.
you can use Postman client.
First : run the API FROM visual studio
Second : go to postman put the url and add the parameter in body
More information : http://www.tutorialsteacher.com/webapi/test-web-api
this often works for me i generally list all of the processes in IIS with appcmd command
appcmd list wp
and pretty much you know which process to attach by seeing the names of the web services
if appcmd is not available please visit
Here for configuring this

Categories

Resources