Hi:
I'm new at ASP.net, i want windows application to send commands to an ASP.Net 2.0 Web Application to perform certain action, either the Web-Site and Windows application within the same solution or isolated.
And if they were within the same solution, how to make 2 projects communicate with each other (Windows to Web not vice versa)
The action is " Windows Application tell the Web-Site to navigate to the next image in a list of images in a folder"
So please help me with anything :-(
Thank you
13 5984
What you could do is "screen scrape" the web application for hyperlinks.
For example. If the web page contains a button whit HREF <a href="newpage.aspx?id=5>Next</a>
Then you should let your program load this page/hyperlink in a new browser window. You can use the "navigate" method in the browser control for this.
See this link for more info on the browser control: http://ryanfarley.com/blog/archive/2004/12/23/1330.aspx
Thank you for your reply, but i want my windows application to fire the next action not the Web-Site User.
The problem is how to make Windows Application send something to an ASP.Net web application.
I don't want the Web-Site End-User navigate or do any thing, the control is from My Windows Application.
It's a uni-cast whiteboard from Windows Application to Web-Application
hi. it really all depends on how "get next image" is handled in the web application server.
if you can get to the next image by changing the url, then you could do as Arnold says and just plain control the current url of the browser instance you have under your control in your windows application (by way of a browser control for example)
if the website will provide you the next image only after you push a button that actually fires some event in the ASP.NET server and then gives you the resulting html, what you need is to connect() to the web server with your windows app (system.sockets.tcpclient) then write an appropriate HTTP request, with POST data faking the fact that it's your application (and not a human) pushing the button.
I'll try to explain further: when a user clicks a button in a web page, it might be that the button just executes javascript code, or it might be that the button actually executes code in the server (it depends on how the website was designed, etc). so if your button is doing nothing but javascript code you can very easily get the next image by setting the appropriate url in the browser instance you control from your windows app. If the button is doing something in the server then you need to provide a HTTP POST request through your windows app that looks identical to the one generated when a human user clicks the button.
If you are in the second situation, I suggest you practice with program "curl", so you can easily see headers for http requests, so that you can tune the POST request you'll have to make to the web app. You will probably need to install cygwin or some other unix/linux emulator if you want to use "curl". Once you know the post request you need to make, just have your windows app make it, and have it redirect the resulting web server's response to the html of the browser instance controlled from your windows app.
Does this help?
Thank You Very much for the connection method from Windows Application to the Web-Site Application, i really understand it and i'll do my best to make it.
but i don't understand the second situation " From Web-Site to Windows Application ", can i add reference of my Windows Application to the Web-Site. so as certain event fired from the Web-Client i send the details to My Windows Application through this ref.??
hmmm... If I understand correctly you would like to notify your windows app about events occurring in the web browser control, like (say) knowing when the user clicked on a link, and which link it was.
Maybe you can get a web browser control that has events, and you can subscribe to its events.
If your web browser control doesn't have this capability, I can't think of any procedure that would enable you to know on which link or button the user clicked, except for an "ugly" one: doing it the way search engines record your click. What they do is they rewrite links to pages so that the links point back to the search engine first, then you get redirected. (try it: go to google and search for something, then instead of clicking on a link copy its location and paste it on notepad and see what it actually reads, you'll notice the link actually points back to google, but the url has the url of the site you clicked embedded on it.
If you want to do it this way, you could for example have your application open a port and listen to it, say port 1234. You would have to asynchronously handle traffic to this port so a callback function fires when something is writing to that port, which presumably will be an HTTP request made by the web browser control. It would have to wait until the HTTP request is complete, and then your windows application can analyse what just happened and if necesary forward that HTTP request to another site.
Your windows application would have to rewrite the links on any document, so that say instead of showing a link as "http://www.thescripts.com" you would rewrite it as "http://localhost:1234?url=www%2Ethescripts%2Ecom" note that the dots have to be urlEncoded so a dot becomes the secuence %2E . What this will do is it will contact "localhost" (which is the name of your computer) at port 1234 and make an HTTP request with that url, that has the final url encoded on it. If you do this then your application would be passed the url the user wants to see, along with any POST data (which contains the values of a form the user is submitting, complete with the information that tells you which button he pressed).
This implies that the windows application has to request the page in the web browser control's behalf, but enables you to rewrite the url's of the page again so that your windows app continues to be notified of more user events.
Remark that you would have to rewrite not only anchor elements (i.e. "links"), but also the "action" attribute in the forms, so that you redirect all events to the windows application.
What do you think?
I Think you are very smart -:) hahahahahaha, really thank you for your thinking, but i want to show you my problem in more details in the situation (From Web-Site to Windows Application), it's about comments, if we go back to the whiteboard that was controled from My Windows Application, the presenter showing his/her slides from Windows Application and the Web-Site User See these slides automatically navigated, at any time the Web-Site User may want to send any question to the presenter to ask him/her about any matter, logically the Web-Site User enter a text this text is to be passed to the Server, then to the presenter. the problem is when the text is to be passed from the Web-Application to Windows Application (@ Server).
Thank you very much and waiting for your reply
hi,
Ok... now that you describe your situation things are clearer to me now. I think you should look into the XMLHttpRequest object it has a wiki page here: http://en.wikipedia.org/wiki/XMLHttpRequest
Because the way you talk about messaging, it sounds to me an awful lot like google talk's implementation that comes embedded in gmail, that's the way they do it. You will like the Atlas framework (also known as ASP.NET AJAX)
Basically you can register javascript functions that run in your browser (and thus have the ability to change and update the current page you are looking at) to server-side methods. This would achieve what you are looking for: 2-way communication between your browser and the web server.
You will also love to read this page about ASP.NET client callbacks: http://dotnetjunkies.com/Article/E80...0EECF13D7.dcik
So in the end you can have messages and a controlled slideshow all in your browser. Web 2.0 style.
Hope you like those links
ummm, i got this, but the one more thing that helps me.
@ My Server Windows Application
public void MovetoNextSlide()
{
//What Should i Do Here to tell the Web-Site to Navigate to the Next Slide
}
@ Web Site ASP.Net Code
public void SendCommentToPresenter(string Comment)
{
//What Code Should i Put here to pass the Comment to Windows Application
}
this is the practical problem that i face
another thing i need your advice in, what's better, putting both MyWindows Application Project and My Web-Site Project within the same solution, OR make isolated 2 solutions??
Hey, how are you?
I just put a page together for you. I mocked it up from a number of pages, especially from msdn pages, I'm sure from here it'll be easier to do things for you. What this does is it creates an ASP.NET 2.0 page where you get a textbox and a button, whenever you press the button, the text from the textbox gets sent to the server, gets processed, and then comes back.
As for a chat application like you want, you would have to adapt this code so that messages go to the presenter instead of comming back to the current page's user. (remember each user watching a asp.net application gets its own thread, so for a message comming from a user to get to another user you will have to deal with communication between threads, which you can achieve for example by having a static object that would qeue messages to the presenter and to the rest of the people).
In a serious chat app you will also have to deal with things like: how do you know when a user has been sent a message? well you'll have to keep a live connection by having a server method jam until it gets a message for your user or something like that. but at least it's a start on having 2 way communication between the app and the server.
About the slide control issue, what I would do is I would have an extra "chat" session with a unified static object that is the same for all users in the server. This chat session would not be controlled by the user, but by the page. The page would "talk" to the static object and the static object won't respond until the presenter wishes to change slide, at which point the object would send to all users at the same time a "reply" string, which will get processed by the associated javascript callback function in the client page and be treated as the next "src" attribute of an iframe html element on your page that presumably contains the current slide (and thus the slide will change)
About the windows application / webapplication solution... If I may be so bold I would suggest that you spare the windows application and just plain do it all as a web app. I think the windows application would only be justified if you need to have access to openGL within your client app. This way you would not need to worry between communication with a windows app, plus your app would be usable from anywhere.
This code uses the XMLHttp object I was talking to you about to create "side HTTP channels" where you can communicate with the others without refreshing the main page, but it does so behind the scenes so you don't have to even know about it.
I hope I was less confusing this time! Anyways here goes the code
Kind regards, memo -
<%@ Page Language="C#" AutoEventWireup="true" %>
-
<%@ Implements Interface="System.Web.UI.ICallbackEventHandler" %>
-
-
<script runat="server">
-
private string ret = "";
-
-
protected void Page_Load(object sender, EventArgs e)
-
{
-
ClientScriptManager cm = Page.ClientScript;
-
string callbackRef = cm.GetCallbackEventReference(this, "argumento", "receiveServerData", "");
-
string clientCallbackScript = "function callServer(argumento, context) { " + callbackRef + "; }";
-
cm.RegisterClientScriptBlock(this.GetType(), "callServer", clientCallbackScript, true);
-
}
-
-
void ICallbackEventHandler.RaiseCallbackEvent(string clientArgument)
-
{
-
ret = clientArgument;
-
}
-
-
string ICallbackEventHandler.GetCallbackResult()
-
{
-
return "received '" + ret + "' alright!";
-
}
-
</script>
-
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-
<html xmlns="http://www.w3.org/1999/xhtml" >
-
<head runat="server">
-
<title>AJAX skunkworks</title>
-
<script type="text/javascript">
-
function receiveServerData(argument, context)
-
{
-
alert("received data");
-
document.getElementById("msg").innerHTML = argument;
-
}
-
</script>
-
</head>
-
<body>
-
<form id="form" runat="server">
-
<div>
-
<input type="text" value="type here" id="txtBox" />
-
<input type="button" value="llamar al servidor" onclick="callServer(document.getElementById('txtBox').value,alert('sending to server'));" />
-
</div>
-
<span id="msg" >Here we go</span>
-
</form>
-
</body>
-
</html>
-
ummm, your word about converting my all application to ASP.Net Application is a good idea but i have a due date because this is a graduation project, i have got an idea to make Windows Application Talk to Web Application, can we use Windows Queues (MSMQ) we will make 2 queues, one from Windows to Web, and the other from Web to Windows. but we will use timers to read from the queue in each applications, is this powerful?
Hi,
I have never worked with MSMQ, it certainly looks powerful. I have 2 thoughts:
1.- Doing it the message-qeue requires that you install your windows app client on all machines, and that you somehow provide these client machines with a way to reach the queue. If your clients aren't all on the same computer or domain, this might be tricky to achieve securely.
2.- If you are going to do it this way, it means you don't really care much if you imposed a restriction on your app that would only make it usable within a certain network.
That said, maybe the ASP.NET part of your application is unnecessary. You could develop an application based on a custom-made application server (with the message queue) and rich clients, but instead of presenting slides, links, and chat sessions through a web control in your app, why not do it with a dynamic windows form that could change its contents on the fly. This way, because you have a windows form instead of a web browser, you certainly have much more power for displaying content and subscribing to events that happen in your windows form. Chat sessions and real-time annotations to the slides by the app users would be possible and way, way easier to implement than through AJAX.
I think doing it with ASP.NET really only adds a layer of complexity because you have to present HTML content to the user with a web browser control, translate user action into HTTP requests, use ASP.NET to translate these HTTP requests into MSMQ messages, and then back to HTML content.
But if you still want to do it this with an ASP.NET tier, I found an interesting read for you in the web: http://www.15seconds.com/issue/031202.htm
I Post my topic at Microsoft MSDN forum at this link:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1563261&SiteID=1
and i got some good ideas, and i'm linking all valuable replies from here and MSDN forum , and i will do the following:
create a web service that have the Business logic, and to send certain message to the web application i'll use the HTTPRequest to faking the invoking of certain code and using Browser instance i'll broadcast this event.
i hope if someone have any advice for me please send it her thanks
What should I do if I wanna simmulate a button click on a web page from the windows application? Thanks in advance.
hi. it really all depends on how "get next image" is handled in the web application server.
if you can get to the next image by changing the url, then you could do as Arnold says and just plain control the current url of the browser instance you have under your control in your windows application (by way of a browser control for example)
if the website will provide you the next image only after you push a button that actually fires some event in the ASP.NET server and then gives you the resulting html, what you need is to connect() to the web server with your windows app (system.sockets.tcpclient) then write an appropriate HTTP request, with POST data faking the fact that it's your application (and not a human) pushing the button.
I'll try to explain further: when a user clicks a button in a web page, it might be that the button just executes javascript code, or it might be that the button actually executes code in the server (it depends on how the website was designed, etc). so if your button is doing nothing but javascript code you can very easily get the next image by setting the appropriate url in the browser instance you control from your windows app. If the button is doing something in the server then you need to provide a HTTP POST request through your windows app that looks identical to the one generated when a human user clicks the button.
If you are in the second situation, I suggest you practice with program "curl", so you can easily see headers for http requests, so that you can tune the POST request you'll have to make to the web app. You will probably need to install cygwin or some other unix/linux emulator if you want to use "curl". Once you know the post request you need to make, just have your windows app make it, and have it redirect the resulting web server's response to the html of the browser instance controlled from your windows app.
Does this help?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: piyush |
last post by:
Sorry for repeated posting but I couldnt get things right/completely
in the first post.
I am in the process of deciding the IPC mechanisms to use...
|
by: piyush |
last post by:
Sorry for repeated posts, I couldnt get things right and complete in
the previous post.
I am in the process of deciding the IPC mechanisms to use...
|
by: Kris |
last post by:
I have a Windows Service in C# talking to a serial port and using Remoting.
It also uses several COM objects. On customer's computer the service...
|
by: Justin Engelman |
last post by:
Hi,
I have a website that uses an ISAPI filter that will redirect anyone going
to any page on the site to an SSL login page (on a different website...
|
by: Blaxer |
last post by:
I have read approximately 30 articles now on various methods to make your
vb.net application automatically update itself and I can't see how they...
|
by: Jessica Weiner |
last post by:
I have an simple application that opens up a windows form. However, whenever
I run the executable, the dos window appears in the back How can I get...
|
by: shyam |
last post by:
I have a C++ COM based windows service which have more than 30k lines of code
and which is stablized over years. We need to take the advantage of...
|
by: Boris |
last post by:
We have a native Windows DLL (let's call it native.dll) we developed a .NET
interface for (let's say managed.dll). When a .NET application now uses...
|
by: Pini |
last post by:
Hi all,
I have a massive windows application that refernces a lot of assemblies
and doing a lot of DAL anf IO operations.
I want to expose this...
|
by: tammygombez |
last post by:
Hey fellow JavaFX developers,
I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
|
by: concettolabs |
last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
|
by: better678 |
last post by:
Question:
Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct?
Answer:
Java is an object-oriented...
|
by: teenabhardwaj |
last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
|
by: Kemmylinns12 |
last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
|
by: CD Tom |
last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
| |