C# local application, to fetch variables from website in an open tab - c#

I am trying very hard to find a way to allow exchage of information between an application running locally (made in C#) and an web application residing in an open tab of any web browser.
That is the typical user case:
User login to the .NET MVC web application using their username and password. Once logged in they are assigned a guid and they are redirected to www.myapp.com/view/[guid] . Once there they are prompted to download and run the local application (or if it's already downloaded, to run it).
Once they run the application, it should detect the [guid] and start posting information to the server www.myapp.com/postInfo/[guid].
Originally I thought about using ClickOnce and passing parameters to the clickonce launcher (?guid=[guid]). But clickonce is only supported in IE - chrome and firefox require a plugin which is a showstopper for me -
Then, I throught about using flash in the webapp to paste the guid in the clipboard, and have the local app constantly check the clipboard, but I don't think this is an elegenat solution, as it will erase the current contents of the clipboard.
Any thoughts on how this can be implemented?

Can you not package a file with the downloadable with the guid in that?
When the app starts; read the guid from that file.
or even better edit the app.config for that application prior to making available for download...
Another route would be altering the .exe prior to making available for download... Modify Emdeded String in C# compiled exe

Related

Select a file from user local machine in .Net MVC C# web application?

I have a .Net MVC C# web application. User needs to select files and uploads to server. For simplicity, let's assume just 1 file a time. Before upload the file, I want to check where the file comes from. In order to do that, I need to get the file's full path on local machine to validate the file. The path has all the information for the validation.
So, the question is: how we can have user select a file from local machine, and we can get its full path? Is it possible?
Or, this is impossible in web application and has to be done in desktop application?
Thanks
You can't for security reasons. It might have been possible on older browsers, but modern versions won't allow it.
In Chrome it won't even display the file path of a selected file in the control, instead showing C:\fakepath

Open local directory from ASP.NET MVC 3 Intranet application

I would like to know if it is possible to open a directory from intranet MVC application ? I have been searching about it but i don't found anything.
I tried to open from javascript using window.open('url') but i get unauthorized access.
Thanks,
Tiago MourĂ£o
IMPOSSIBLE !!!
web browsers does not have allow web pages to access to disk drives.
web pages only can read/write cookies.
FileUpload control allow access to the files, only with user action(scripts no allowed).
I found a way to do resolve this problem. If you create a background process using Process.Start('location'), the application opens directory folder.
Tips:
Process.Start() generally used in windows application and if used in
web applications, a process will start on server(not on user agent
that run current page).
you get unauthorized access error, because of IUser has limited
access ...
1) Web Applications can read/write any file and folders on server side with assigning permission.
2) WebApplication with Some sideway can access to file & folders in web pages (client side) !!!
with JavaScripts:
Write a browser add-on with requested functionality, then install on
user agent(browser).
now with call method/function in add-on, you can do the operations
that does not allowed with JavaScript & etc.
with VBScript(Obsoleted) that run/supported only in MsIE:
can using FileSystemObject to full access files and folders.
can using CreateObject to create instance of each object in OS and
working with it.
Finally my answer is IMPOSSIBLE.

Read an xml file from different computer on the network?

To begin with, I developed a web application which reads an XML file from specific location and displays the contents on editable web page of the application,which is executed perfectly when the XML file is on the same machine/computer. When I try to read the same file on different computer on the network I cannot read the contents onto my web page.
My Observation:
When I access that file from run window in the computer by entering \xxx.xxx.xx.xx\c$ it gives me the window to connect to the machine asking for credentials and I guess the session is open. So I close the window and when I access the xml file from the web application it's able to read the content.
Is there a way to bypass this authentication mechanism which is part of windows when I use my web app to read the XML file or is there a way to accommodate the extra step to configure the authentication in my application?
I would be glad if someone can guide me to the solution.
Check the user your web application is running under and if this user is also permitted to access this location.
If you are using IIS to host the page you have to check the "AppPool" user and also the users which are used at the "Web Site" and "Application"
Just change IIS application pool user to "enough rights" user (right click current app pool - advanced settings - identity) or specify impersonation in the same name section in web.config.
Could it be possible to change your logic,
By storing file from different network to local machine where your code is running, through uploading file and process it.

Open .NET app from Web Page

I just need to be able to open a .NET app (click once) from within an ASP.NET web page, and pass 2 string parameter to the app.
How can I do this? Any example please, with any method to do it. Thank you in advance.
This article explains how to retrieve the parameters from the querystring used to call the ClickOnce app. That should help you to figure out how to compose the URL, along with its querystring containing the parameters you want to send.
You could associate your application with a file extension and then simple generate a text file with your parameters from the web application with this extension and that would be opened by your client application.
Edit: If your click once application is deployed from a web site you could just link to that url. Depending on the click once settings the app could be started from the client if already installed.
There are two ways to deploy a click once app - so it can be launched from the start menu, and so it can be launched from a URL. Assuming you have set the app up as the URL-started one, just have a link on any ASP.NET page (or could be pure html, doesn't matter) to the click once app's URL. When the user clicks it their browser, IIS, and their local copy of Windows will all do the work to get the app launched.

Permissions for writing a file

I've the following issue
I've a windows application
It calls a remote web service (for authentication)
It in turns call a web service (in the same remote machine) (to get a licensed file)
It saves the licensed file in All Users/Application Data in the system where the application is running
Which permission is used for saving the file in the Application Data folder? Either the web service's or the currently logged windows user's?
Update #1
So, i'm not able to save the license as the web service call is throwing a save error. How can i check the permissions of the folder?
Here is the code for creating my folder
licensePath = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MyApp");
if (!Directory.Exists(licensePath))
Directory.CreateDirectory(licensePath);
Update #2
If i try to save it in the application's path itself (in bin/debug while debugging the application), it is working fine. Any ideas? I've tried just "C:\test" too. It's not working.
Thank you.
Regards
NLV
It will save the file with the permissions of the user that is running the windows application (which can be different from the logged in user - see RunAs).
The permission the windows application is running in.

Categories