send messages between 2 asp.net web applications? - c#

I have 2 web forms applications written in c# asp.net. This is the kind of thing I need:
A user clicks a button in web app 1
Web app 1 needs to send some parameters to web app 2 and get a response
Web app 1 uses the response from web app 2 to finish processing the post-back
User is happy
So I guess I need to incorporate some kind of web service thing into my web applications? Please point me in the right direction.
Update:
I've done some more research and found that WCF seems to be a goer. I have used WCF once before (stumbled through it) but how do I use WCF inside a web application - or do I need to create another application just for WCF?

Inter-process communication is a pretty large topic and there are many ways to do it.
Some tings to consider are
Synchronous vs Asynchronous - What should be the behavior if the user clicks the button twice in quick succession?
What should happen if user clicks the button but the web app2 is down for a few minutes?
Authorization and security
Denial Of Service style attacks
For something of this nature I would be inclined to use something like a message-queue maybe managed by something like nservicebus it would be a very simple, yet robust solution. WCF is another option and so is MVC 4.0 web services.

Related

Two way web service communication in wpf

I have a WPF application that needs to send and fetch data to and from a web application. Web application is built using ruby on rails.
What's confusing me at the moment is does the WPF application need to have a web/wcf service on it's own to talk to the rails web application web service. If not how can i fetch and send data to and from the rails web application web service.
Please note that I have done some digging around google and here but am still confused since most of talk of creating a asp.net application first. A step by step best guess scenario/example would really be helpful.

Web Forms and Web API Deployment

Good old Microsoft documentation at it's finest. Does anyone know of any resources that explains how to deploy Web Api with Asp.net Web Forms application. I have the web api in a separate class library and I call using jquery. I don't want anonymous users to be able to access this service only the application. Do I want to use self hosted? How do I lock the service down? Awesome examples showing how to use, tons of videos but nothing on deployment.
You don't have the right architecture for what you are describing, but what you have is right.
If you are calling web services from the client side (using jquery) then your web service must be public facing.
What you are describing is a web or WCF service in a service oriented architecture. That service would most likely live on a different server and be on an internal network, etc. Even if it's on the same server your requirement is that it is not publicly accessible - thus none of your jquery would work since that request is being initiated by the user and users can only make requests to public facing services.
The comments about using forms authentication to protect your service calls are right. jQuery will include the forms authentication cookie for you when it makes AJAX calls so you shouldn't have to change much on the client side.

Move UI of Windows Forms .NET application to web

I have written a windows forms (.NET C#) application that encodes video and is essentially a GUI for ffmpeg.
The requirement has changed, and we now want to move the UI to a web page and have the encoding done as a windows service.
The following requirements also apply:
Two-way communication between browser's web page and service (i.e. start encoding using web interface and have service notify progress back to web page)
Service should be ported to Mac OS X too
UI should be a standard webpage (should consist of HTML/CSS/JavaScript/Flash etc...)
I was thinking of WCF for the windows service, but I have zero WCF experience.
Will WCF provide a good basis for 2 way communication between the web page and the service?
Also, I need to think about porting the service to Mac OS X, and I noticed that WCF is only partially implemented in Mono (see http://www.mono-project.com/WCF_Development).
Will this be an issue? Does anyone have any experience with WCF development in Mono?
What would be the best route to meeting the requirements above?
I would love to hear any suggestions...
EDIT
I should clarify - this is not a web application, it will run entirely on client side.
Service should run client side and interact with a webpage inside a browser (which is also client side).
If you want a UI in HTML – which is what a "UI to a web page" would mean to most – then WCF is the wrong approach. WCF is for creating highly interoperable (WS-* standards) clients and/or servers; not for web pages.
Better looking at ASP.NET MVC. This is a very different model to WinForms,1 but allows easy moving from from rendering a UI into HTML to generating XML or JSON for a Web API (behind AJAX from a Web UI or a native client).
As I understand it ASP.NET MVC is substantially supported on Mono; and this should become easier with much of ASP.NET being open source now.
See also this answer from yesterday.
1 WinForms would be less of a move, but it would then be harder to do the API side without another technology shift (albeit ASP.NET WebForms and MVC can be easily mixed in one Web App).

Integrate an E-Mail server into ASP.NET

I've a general design question:
I have a mailserver, written in C#.
Then I have a web forum software, written in for ASP.NET in C#.
Now I'd like to integrate the mailserver into the ASP.NET forum application.
For example, I'd like to make it possible that one can create a mailinglist from the forum, and give users the oportunity to add oneselfs to the mailinglist members in the forum, and then add the new list-members to the respective mailinglist on the server.
Since the server is a separate console/winforms/service application, I first thought I'd best use .NET remoting for this.
But my second thought was, that some users might host their forum on a host where
(a) they don't have a virtual machine where they can do what they want
(b) the admin of the host might not want to install an additional mailserver or charge extra for this
(c) the user might have a service plan that only permits to add a web-application, not external programs (very likely)
Now, I wanted to ask:
Is it possible to fully integrate a mailserver into an ASP.NET application somehow ?
(I have the full source of the server + ASP.NET application)
Well, it probably won't be a page or a ashx handler, but something like a http module ?
Or what's the general way to integrate TCP/IP applications into asp.net ?
(Of course I'm assuming the respecive ports are available/forwarded - and I'll make it possible to also run it with the e-mail server as external application)
In the ideal case I'd do the following:
Set it up on your own server(s) and expose a WCF/web service that your web app will/can interact with.
If you can't or don't want to afford to keep it running on your own, you could then charge a subscription fee for it.
It's probably not a very great idea, but you can start a thread in Global.asax and do background processing while the application pool is running/the web app is not reloaded. So you could start your server there, but you have no control over the lifetime of it
Adding to chris166's comment... you also wouldn't get control over when the application is started. [Since the application won't be loaded until a page is requested...] Its probably a better idea to setup some sort of integration between the web app and the console/service app.
I'd probably tend towards setting up a near-realtime integration where the mailserver polls the forum app for requested changes.

Best Practices for Exchanging data between Desktop and Web Application

I have to pass information from a desktop application to Web application and vice versa.
What are the best practices that are regularly used?
Currrently I'm using Asp.Net and a Winforms.
To pass data to Web Site im creating a (POST) WebRequest and posting an xml to the site.
To pass data to Application im using .Net Remoting from Asp.net
(I'm using Winforms is an adminstration and monitoring application.)
Edit: Lets treat it as a generic web app and winforms.
Also currently both Web app and Winforms are on the same machine.(but can change).
Web Services or Windows Communication Foundation (WCF) would be your best bets for remote interoperability.
On your website, expose some service end points and consume them from your desktop app. Then send messages as you require.
I'd look hard at the design of the system and consider whether it's necessary to use a Winforms application at all for monitoring and administration. No, really: creating rich Web sites is quite straightforward (if necessary, with technologies like AJAX) and the architecture of the resulting application will be much, much simpler.
And, of course, deployment is then really simple.
I am not sure if there is a best practice for what you are trying to accomplish. There might be some security concerns you have to think about when allowing posts to your web application however. It would be very easy for a potential attacker to manipulate the post data and send it to your web application. You should consider using web services or Windows Communication Foundation.
Register a custom handler like how Real player registers rstp:// or for that matter web browsers register http://

Categories