Can we add a windows form in an asp web page.
Like if someone click on a button on web page(.aspx) user receive a windows form (.cs)
and then again switch to each other.
It cannot be done.
The closest thing to do this would be to use Silverlight embedded in the browser.
No there is not any way to do this. Your only option would be for the user to click a link, download an .exe and then have the user launch the application.
The reason for this is that Windows Forms are designed to run on Windows, and run with a different permission set. As such, a web application first of all could be running on a non-windows platform, and secondly, does not have the ability to actually launch an application on the users machine.
In short, no this cannot be done.
You can't embed a windows form application in a webpage.
RIA (Rich Internet Applications) are what HTML 5 is about, and currently flash and silverlight are the closes things to what you are looking for.
As #Mitchel Sellers mentions, you can always link to an exe, save it and execute the downloaded file, but this is far from seamless.
Even if you did add some windows form UI (for eg a message box) to your asp.net application it will only be fired on your web server.. no client will ever get it on their side
I'm not exactly sure why would you need this? But the closest you can get to this is like "Mikael Svenson" said, Silverlight..
Related
A few years back I developed a Silverlight Component called from within an ASP.net web app, that uses PInvoke to access a USB (Serial COM port) on the client machine to allow for sending commands to some scanner hardware.
With the advent of Windows 10 and the inevitable demise of Silverlight I am looking for alternatives to accessing hardware on the client PC (This is all Intranet Web Application stuff where we have a lot of control over the implementation)
Currently I am looking at Registering an Application to a URI Scheme (Easy solution) as per this page:https://msdn.microsoft.com/library/aa767914(v=vs.85).aspx
OR alternatively maybe Javascript navigator.msLaunchUri (This seems to not be supported in Windows 7, which we need to still support)
Refer: https://connect.microsoft.com/IE/feedback/details/864863/documented-api-function-navigator-mslaunchuri-not-present-in-windows-7
The Registering of an Application to a URI Scheme works fine in Windows 7/8/8.1 but seems to have changed in Windows 10 - Does anyone know how I can implement this (Through C# code, registry, something) to allow this to work in Windows 10
I recently wanted to just this as well - and I found the answer so i'm posting it here for future reference and I couldn't find a working example in C# anywhere.
First of all your app needs requireAdministrator permissions. To do this, right click on the project in the Solution Explorer and click Add New Item, then select General and finally Application Manifest file if you don't already have one. In there, change the requestedExecutionLevel to requireAdministrator. Save.
I this is the first time you've done this, you'll need to restart Visual Studio as it probably isnt running under Admin privaleges.
Okay, so I wanted my app to create the registry key when it starts up, so in the constructor for my form I put in the following code, which creates the URL Protocol foo:// for a program called 'oggsplit.exe' (which I happened to have in my C: root so I just used that for testing)
RegistryKey key;
key = Registry.ClassesRoot.CreateSubKey("foo");
key.SetValue("", "URL: Foo Protocol");
key.SetValue("URL Protocol","");
key = key.CreateSubKey("shell");
key = key.CreateSubKey("open");
key = key.CreateSubKey("command");
key.SetValue("", "C:\\oggsplit.exe");
Once you've configured that, save and run the program. You'll get no feedback, and as long as you don't see any errors it should have worked correctly. Now, open your browser (no need to restart or anything) and go to the address foo://hello. This is what it looks like for me in Google Chrome:
It will then ask you if you want to open your application from the browser, click okay. Hey Presto, your app opens from the browser, you can now put a specilised link into your web page to open your app from the browser. This Page also documents how to pass arguments through to your program as well.
In win10 you can try to use URI handlers. There should be Package.appxmanifest file where you can list URIs that should launch your app.
Also, I found interesting the folowing article that describe web-to-app approach for various OS
I am trying to open my app's Login Form whenever I try to double click and open any web browsers installed on my system. I have spent around a week without any success. Any help, articles, code or links would be of great help.
Thanks.
I am using Visual Studio 2010
Programming Language : C#
Trying to intercept every browser launch probably requires monitoring the system processes. I.e., your app will constantly be running and whenever a recognized browser process starts, you spawn your login form. There may be system events to hook into (I am not sure), but How can I list all processes running in Windows? might be a good starting point to get an idea what's possible.
A somewhat different approach would be to register your app as the system's default browser. That way, you will be notified, can spawn your LogIn form and can than delegate to an actual browser.
I am not sure what ultimate goal you pursue, and whether either is a good solution depends heavily on whether there are more constraints to it than you mention explicitly.
In order to open a link with your default browser, use the following code.
System.Diagnostics.Process.Start("http://google.com");
You could compile your own Firefox-Version which contains a login form, but you would need a few more steps to prevent a user from launching a start-only browser like the TOR-Browser-Bundle.
I'm currently trying to move over a screen-scraping program (c# forms application) to a WCF service.
The screen-scraping program uses WebBrowser to grab info off several pages for which there is no API. I would like to know if you can run WebBrowser in a service let alone a form. I'm currently developing on XP to be release on Server 2003.
Currently when running unit test, I can only see the WebBrowser if it was made on the "Unit Test" side and even then I need to manually pop up MessageBox'es to get WebBrowser to stop from not navigating with a blank screen.
The program is being moved and split up since we are having multi-threading issues.
You would be better off using a headless browser like Phantom.js: http://www.phantomjs.org/. It offers significant features and has no problem being executed wherever you need like a regular command - line program.
In thinking about this, realize that each instance of the WebBrowser control is actually an instance of Internet Explorer. Your question then becomes one of having a service start multiple instances of Internet Explorer.
But Internet Explorer is an interactive application. It expects to control the keyboard and mouse when it has the focus.
Which keyboard and mouse do you want it to control when running in the server?
How many keyboards and mice does your server have?
You could find some way for the service to launch a Remote Desktop connection and start up your Windows Forms application. You could then have your Windows Forms application host a WCF service, and the two services could talk to each other. I have seen this sort of thing done when it was necessary to automate a specialized interactive program which could not be made into a service.
Im looking for some advice on an application im creating using a windows service. Basically we have some timesheet software and i need to create a windows service that will poll a db to see if they have completed last weeks timesheet. If they havent completed it i want the application to popup a message stating that it is incomplete and that they should go and complete it.
Ive created a simple service from a tutorial i found and got it to install and run fine. I now need to think about the form side that popups up. Thing is im not sure its a good idea to do this from a service. Can anyone give me a steer on the best way to develop this application using a windows service.
as mentioned earlier you may not create userinterfaces from within Services. In order to achieve this. you have to build another application. you can use Windows Forms or WPF for building the NotificationArea inteagration application.
I would use WCF with net tcp binding to communicate between both applications.
Well as you aslmost said your self. This is not well suited for a windows service since there is nothing going on when a user is not logged in. If on the other hand you were also sending mails AND showing pop up a duel approach would be ideel.
I recommend scrapping the service and only use your form.
You could develop ANOTHER WinForms application that reads from a Database (for example) every X seconds
Your Windows Service will write to the Database indicating whether the job is done or not.
once your Winforms application (that can sit in the system tray for example) reads from the database and sees the job is not done - make it pop up and alert the user.
Just a thought!
To summarize, as we all know,
a) Silverlight is expected to be hosted by a browser, and runs in an isolated sandbox so that there won’t be any security issues
Silverlight don’t have direct access
to the file system, other than the
isolated storage area
There is no
direct way to open common dialog
boxes like File Save in Silverlight (Though Opendialog box is supported).
b) Silverlight can’t access local resources like a printer
What are the ways to go beyond the sandbox, so that I can host a Silverlight application locally, to read files and save them back if required, to hand over data to a printer, and so on..
Update:
Is full WPF is not an option for me? No. I'm also interested in a cross platform solution - for instance, you could host Silverlight in Mono Web browser control, so that you can run it virtually anywhere.
The idea is to re-use the same application that I'm building for web in my desktop as well, by providing separation of concerns at some areas - like persistence, resource access etc.
Scenarios:
1- Some kind of gadget container, with access to local resources.
2 - A desktop Silver light based media application
Update:
I just did a POC to enable me to access printer and save files locally, of course through a shell where I'm hosting my Silverlight application. If you wan't you can have a look at the post here in my blog
Two ways I can think about is,
Create a "Shell"
Host the HTML Page with Silverlight, in a Winforms desktop application, using a web browser control, and communicate to and fro using HTML DOM. Then I can request the hosted shell to do things like printing. See details here
Mono also has a web browser control - based on FireFox XULRunner instead of IE - not yet succeeded in loading Silverlight inside that. Another option might be using Webkit.
Embed a web server
Embed a light weight web server with in the Host application, and handle requests to perform such operations. You can probably define a protocol on top of HTTP for things like saving to a local folder, sending data to print etc.
Is a full WPF application not an option for your situation?
As you probably know Silverlight uses a subset of WPF so you may be able to change your application relatively easy.
A wpf app would be easier than having a web server etc bundled within your application.
You wont in the foreseeable future be able to have access to resources such as printer and files (apart from isolated storage) through Silverlight as you know.
You could have a seperate part of your app to upload files to the webserver then read these in your silverlight app from a service.
Depending on your printing requirements (e.g. if you just want to send everything to an office printer) you could send the informaton you wanted printed to a service that will then print it for you. However I am guessing you want each client machine to be able to print in which case this wont work for you.
I am attempting to also reuse a codebase for both desktop and silverlight. There are two options that I know of in addition to the ones mentioned
If you directly reference (instead of a project reference) a silverlight dll from a normal project, it should work. This would let you reference a silverlight dll for both projects.
Have two project files (one wpf, one silverlight) that point to the same set of files. You might have to have to use a few compiler flags here and there, but this should let you use the same files for both.