Siverlight talk to server using WCF - asp.net

I am doing an simple Siverlight app talk to server using WCF.When I run the app in visual studio,it works fine .However,when I hosted unders IIS,the data from the server will never returned.
Can anyone shine some light on this and how can I debug silverlight app with WCF?

you can try fiddler.
or enable wcf logging on a website that hosts your service, which will give you even more information. Read more here.

Are you receiving any kind of response from the server at all? Are your silverlight applications configured to reference the correct web services (not the visual studio web server)? Can you browse to your WCF services in the browser and get a response?
www.example.com/myservice.svc
Just a few ideas...

Use Attach to process. Remember Silverlight is running on the client so you can open the app in IE and then attach visual studio to it.
You may also want to look at Fiddler to check the traffic is going to the right place.

Related

Deploy a desktop application from a web site

I have a requirement to install a desktop application written in visual c++ when our customers log in our asp.net web site. The desktop app will be installed once, but will be updated as a newer version is available. What is the best way to do this?
My second question is that is there a way for my asp.net web app to interact with a window service installed on customer computer and direct the window service to control USB devices.
My work uses software by a company called Citrix. There is some client side software that goes on the client's PC. When setup correctly, we can click a link on our sharepoint site that will trigger the citrix client software to launch a WPF desktop application from a network drive that will run locally on the clients computer (might be in a virtualized space that Citrix creates). This seems to work well, it runs our WPF applications that use windows authentication. This is all I know about it. You can research more if you're interested.
To answer that second question... Your window service would need to expose some kind of service for the client (asp.net web app) to communicate to it with. So ideally I think setting up the windows service to host a WCF service inside it and use something like named pipes or HTTP protocol to communicate with your application. I don't know what kind of USB devices you are trying to control though, that will take research on your part. But if you can control them with a local console application, you should be able to do the same with a windows service.
Good luck. Hope this was helpful.
You can't install an app from a web site, best you can do is prompt the user to download the installer. And asp.net (or any website in general) can't interact with the window service on the client. Imagine going to a website which changes your service settings, installs viruses, etc. A website is pretty much limited to changing cookies and local storage on the client, anything else on the client is inaccessable.

service discovery during "Add Service Reference"

i'm building an Asp.Net app (contains the service) with Silverlight control (need to use the service) and having a problem after i discover the service and press OK button, can anyone help me please?
Try/Check the following:
Your service project is being properly build with no errors.
There is no other IIS / IIS express servers running in background.
Try to open the service address that you are trying to consume in the browser and see if it is loaded OK.
This should give you a lead on the problem.

Want to run my own server instance with special port for an ASP.Net 4 based solution

I have made an application in asp.net which sends and receive sms, it works very similar to desktop application and it will be installed on servers to send sms alerts, but the problem is if server does not have iis, it will not work. I have seen many apps which when installed, have their own server and port, you do not need to install any IIS, when you just double click it starts running on a special port and works well, similarly visual studio also runs its own port in development mod, so what is the best way to make such solution for an asp.net product.
If you're talking about how to host a service in an application outside IIS, Windows Communication Foundation (WCF), which allows you to host a service in a Windows Forms executable, Console Application, Windows service, or IIS.
It's too big a subject to explain fully here, but there's a nice starting point here.
This will allow you to create the host, and allow you to hose services similar to web services, but with more options for how to connect. (http, tcp, etc.)
But it's not an ASP.NET host. For that, you will need a web server that can execute ASP.NET, such as IIS. There's no way to get around the need to have a web server, whether it's one of the many already established, or if you write your own. I believe there are extensions for Apache that allow you to do so via Mono, but I've never used them. Writing your own would be, in my opinion, a waste of time and a bad idea.
The simplest solution by far is to specify that IIS instaled with the appropriate framework is a requirement for using your website.
Edit
However, if you REALY want to write a WinForms app and have it host ASP.NET, it looks like this previous question has an answer that would help. You can use the Cassini web server, the same one that Visual Studio uses.

Silverlight failing with Cross Domain Error

I have an application that is built using ASP.NET, with an embedded Silverlight Object that communicates with a WCF back end. It is set up like so:
Server 1: Hosts ASP.NET Website on IIS7
Server 2: Hosts WCF Application on IIS7
My Machine will try to access Server 1 over the internet to log in to the website. Server 1 will the authenticate the user using the WCF Web Service over our internal network on Server 2. I can do this but when it loads the silverlight object it crashes, complaining about CrossDomain/ClientAccessPolicy failure. So to be sure I put those two files on every folder in the inetpub/wwwroot on both Server 1 and 2, just to be sure. But I am still getting the same error.
When I run the application from Server 1, it can connect to the site through its local network IP and it all works, it also works when I run the ASP.NET application from Visual Studio 2010 on my own machine, with the web service references pointing to Server 2.
I am almost at my wits end, there have been so many red herrings that I have tried and none have worked. I am not even sure if it is Silverlight/WCF or the IIS configuration on each server that is breaking it.
If anyone can help me shed some light on this I would greatly appreciate it.
Thanks,
Stuart.
one idea could be to use fiddler and find the request which is making crossdomainpolicy xml request. Is that failing? Check the address it is pointing to. I debugged my issue using that. It was pointing to root of the server and my crossdomainpolicy xml was in WCF project folder.
I found the issue to my problem. I was not realising that the Silverlight application was trying to access a web service that was restricted by firewalls, so I had to create another web service that would re-route through the website and to the original web service.
What a bloomin' pain!

How to run a leightweight ASP.NET MVC application that would be accessible only locally (not on IIS)?

We have a desktop client application and recent customer requests indicate that they would like to have some dynamic HTML content served and displayed by the application.
We are considering hosting a simple ASP.NET application in a local process, accessible only from the local machine (similar to the ASP.NET development web server used when debugging from Visual Studio).
How can we run an ASP.NET application locally without IIS? IIS is not an option because most client machines will not have it installed.
Is there a leightweight ASP.NET web server that could run locally similar to the development web server that VS is using?
I have found some information about "Cassini". Is this suitable for production use? Can it handle ASP.NET MVC? Are there any alternatives we should consider?
I have not used it myself, but you can try the mono XPS server.
It is a stand alone webserver.
The easiest way to start XSP is to run it from within the root directory of your application. It will serve requests on port 8080. Place additional assemblies in the bin directory.
Cassini is in fact also a good option - it is the development web server that comes with visual studio (so widely distributed, used and tested) and is also used by the open source ScrewTurnWiki. See wikipedia.
In regards to your "only locally" requirement - a web server will serve any request made to the right port. In order to limit accessibility, you should use a firewall that will block any external requests.
You might consider using WCF to host a service on the local machine that can serve the data without having to host a full blown web server.
If you do this, WCF allows you to expose the service with multiple endpoints and make it available through HTTP, TCP, or Namepipes. Namepipes would restrict traffic to only the local machine.
I have also tried IIS Express. It works great with ASP.NET MVC. Right now it is available only with Web Matrix, but installing web matrix is easy.
Coming back to this question three years later, ServiceStack.NET with self-hosted option seems like a good choice. While it is not ASP.NET MVC directly, it provides a good API and features are on par with ASP.NET MVC/WebAPI (or in some ways better).

Resources