I have an ASP.Net application deployed on the server. I want to know whether it will be able to access my local system exe files on button click.
I read a lot of articles regarding this on the Internet. Some are saying it is not possible for the ASP.Net application to access local programs. While some were suggesting that it depends on Permissions, identities and other things .
I tried a similar thing on my local machine but even after giving access permission to Local System, Network Service for the file and even changing the Application Pool identity to local system, i was not able to accomplish the same...
So i just want to confirm whether this thing is possible or not...
Here is the code i am trying to execute
Dim pstartinfo As New ProcessStartInfo()
Dim p As New Process()
pstartinfo.WorkingDirectory = "D:\VS2010Projects\SignatureCaptureWindows\bin\Debug"
pstartinfo.FileName = "SignatureCaptureWindows.exe"
pstartinfo.CreateNoWindow = False
p = Process.Start(pstartinfo)
p.WaitForExit()
If (Not p.ExitCode.Equals(0)) Then
Response.Write("Image Successfully saved in Database with ID = " + p.ExitCode.ToString())
DisplaySavedImage(p.ExitCode)
Else
End If
On running on locahost, it works fine.. When i deploy it on my Local IIS, it doesn't open the exe
It is possible and requires that the application pool user has permissions to the location of the executable and permissions to execute it.
You can use the Process class to execute pretty much anything (even with different user credentials if needed).
Don't forget that trying to run an application with a UI will not generally work well, as the application pool does not run in an interactive environment (so, it can't open windows and click buttons).
You should limit yourself to executables that are not interactive, as the web server will not be able to interact with windows and such.
In your specific scenario, where you need the user to enter their signature and it gets saved - you need them to upload the signature (I am assuming an image file exists already), or create such an image on the client side (say with canvas and JavaScript). You could then upload the image and save it.
Related
i'm trying to open launch Excel specifing an existing file to open. This is my code:
Protected Sub fileManager_SelectedFileOpened(source As Object, e As FileManagerFileOpenedEventArgs)
Try
Dim FullName As String = e.File.FullName
System.Diagnostics.Process.Start(FullName)
dvFileError.Visible = False
Catch ex As Exception
dvFileError.Visible = True
lblFileError.Text = ex.Message
End Try
End Sub
In the e.File.FullName i can found the file's name with its path, so when i launch it as process it should open the Excel's file.
So this code works on local, but when i upload it on a web server it not works. It say "An error occurred in sending the command to the application".
I've created a .txt file to test if my application can access to the folder an i take this the "Access is denied" error.
It is strange because if i open the same Excel's file using a ASPxSpreadSheet Control of DevExpress, the file is opened.
Any solutions?
Your web service can't just open an executable on the client in normal circumstances. There's a few exceptions:
Your web server has admin privileges on the client. This typically only happens in a company LAN scenario
Your web service is the same machine as the client.
You have some sort of software running on the client that can launch the program as necessary. This requires technology outside of the web HTML/CSS/JS sandbox of the browser.
You were operating under #2. But as soon as you switch to remote clients that isn't going to work. You can't use System.Diagnostics.Process to start applications on a remote client. And you can't directly access files on the remote clients machines. Your VB.NET code is running on the server, not on the client. Only your HTML/CSS/JS runs on the client, and that's in the limited sandbox of the browser.
The general pattern to accomplish what you want is just offer a file for the user to download by writing the file to an HTTP response. The user can then open the file and it will launch their default program for editing that filetype.
Before I start, I can tell you that this is one of the worst things that you can do - is to run Excel application on the web server.
If you need to read or save Excel file(s) use Microsoft.Ace.OleDb.xx (xx-version). It will allow you to work with Excel as if it was regular DB. Moreover, if in connection string you give file name of the file that doesn't exist, it will create it.
Remember, you're on the server. And your application runs in application pool. The application pool runs under some user account, which may not have permission to open any user interface.
I remember, we had an issue with Windows service and Excel automation. Excel needs the account, which runs it to be literally logged on into machine. In other words, you need to use the credentials of the account that runs the app pool to logon into this machine. Only then Excel automation will work.
In any case. When you do Excel automation first thing you need to do is to open Excel once to get rid of all the dialogs it displays from beginning. And until you click them off, each instance will keep on showing them even if you don't see them or instance.
And last couple words - you need to use some interop assemblies, not just process.start. It will take care of some things. But Microsoft told us - they do not support or recommend Excel automation, although, admit - it is possible. Returning to paragraph #2 - to write or read data do that, not what you do. You can do #2 in IIS process. But don't do automation in process - very bad idea.
I am about to embark on the development of a line of business application using the Universal Windows Platform (Windows 10). One of the requirements of the application is the synchronisation of data from a server to a local SQLite database; this is required because the application needs to be usable where there is no network connectivity.
It is likely that multiple (windows domain) users will be accessing the application on the same device, sometimes simply by "swapping users", other times by logging off the first user and logging on as a new user.
I realise that UWP applications are installed at a user level, however I would like to be able to share the SQLite database between these users instead of forcing each user to download their own copy of the data.
Is this possible? I am struggling to find any reference to this kind of sharing within the Microsoft documentation - but of course that documentation is new and far from complete!
I guess at the end of the day I am looking for access to a folder that is accessible by any user running that application on the same device, such as the "x:\Users\Public" folders that are available from the desktop, but without having to ask the user to provide access to that folder via any picker control - instead simply being able to "open" it.
Thanks.
In case anyone runs across this, this functionality is now available as described in this blog post:
We introduced a new storage location Windows 10, ApplicationData.SharedLocalFolder, that allows multiple users of one app to share local data. Obviously this feature is only interesting with devices that will be used by more than one person. For such scenarios, for example in educational uses, it may make sense to place any large downloads in Shared Local. The benefits will be two-fold: any user can access these files without the need to re-download them, also there will be storage space savings
Keep in mind that Shared Local is only available if the machine has the right group policy, otherwise when you call ApplicationData.Current.SharedLocalFolder you will get back a null result.
In order to enable Shared Local the machine administrator should enable the corresponding policy.
Alternatively, the administrator could create a REG_DWORD value called AllowSharedLocalAppData with a value of 1 under HKLM\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\AppModel\StateManager
Note that data store in ShareLocal will only be persisted as long as the app is installed on the device and won’t be backed up by the system.
In Solution Explorer , Right click on Package.appxmanifest then click on ViewCode , end of this file in both projects add below code :
<Extensions>
<Extension Category="windows.publisherCacheFolders">
<PublisherCacheFolders>
<Folder Name="FolderName" />
</PublisherCacheFolders>
</Extension>
</Extensions>
After that in code you can access this folder with below line of code :
StorageFolder sharedDownloadsFolder = ApplicationData.Current.GetPublisherCacheFolder("FolderName");
It`s so important that the folder you will share between two these Apps depend on same publisher info at Certificate File [ProjectName]_TemporaryKey.pfx , if this Certificate File and publisher Info of app is same in both Projects , then you can access the same SharedFolder in both application and use it for create or use dataBase file(like SQLite Database file) or other files that need to be share in both applications.
I am using asp.net C# 4.0
I have a batch which will open a text file.
Batch File query
ECHO OFF
start D:\accounts\request\08__processing\0377e792-4ca9-4550-b78c-de2bdf26611f.txt
ASp.net Code
System.Diagnostics.Process.Start("D:\\bacthFile.bat");
when i double click on the batch file its opening the text file.But when run above code its not opening any notepad.
it is not showing any exception also.
Please Help
Thanks
This is the wrong way to read a text file from ASP.NET, you need to use System.IO and put files you need to read somewhere where ASP.NET can get at them, eg.. App_data. That said, here is how to do it the wrong way: IIS runs on an invisible virtual window--it's a service. There is a way to get some services to display the UI, I forget how. In any case, you'd have to RDP onto the server, to see such a window after starting the service and goosing it into displaying a UI (this trick might not even work for IIS).
Next, as commenters noted, on IIS, you'll have one set of credentials different from your own (depends on what version of IIS)-- in any case, it will have restricted access and be somewhat sandboxed. If you set up impersonation and windows authentication in the web.config, sometimes you can get your request to run with your credentials.
Next, if the web host runs in medium trust, you might not be able to launch arbitrary apps from the asp.net appdomain.
Finally, the only way this could ever work is if your app is always running locally with casinni (the visual studio development server)-- but in that case, you could simplify things a lot by using a console app instead of asp.net unless you really need the HTML templating, say for output.
I have an asp.net web application and I want to run an executable. The user will enter some details and I will pass those details as a parameter to the exe. The exe will then generate a text file and I will read the contents.
I do trust this executable..but I don't want to compromise security on my web app in order to allow an executable to run.
I read a little in an MS website about creating a sandbox within the web app.
What's the best way to do this? Anyone know?
Currently trying this with no luck..it should create a text file like it does when I run it from a commmand prompt..
Dim process As New Process()
process.StartInfo.FileName = Server.MapPath("~/app_data/myfolder/myexe.exe")
process.StartInfo.Arguments = "/t:1234"
process.Start()
I get a messagebox asking whether I can trust the publisher, but when I click yes I get no text file. Are the arguments being passed correctly?
Thanks,
I am running an asp.net application (VS2008/.net 3.5) and when running it under VS in debug more it works fine.
It reads files and directories from a network share happily.
I can run "cleartool startview [dynamic view name]" ok, I can "cleartool mount [vob]" happily.
But if I try to test for the existance of a file within the vob it can't see it.
So I tried something different, I now run "cleartool ls -short -vob_only [filename]" to test for existance.
For both of those it works fine running under VS2008 but won't work when running under IIS post deployment.
I have the set and the user has valid access to ClearCase.
Any ideas?
If you use the built-in webserver (Cassini) during development the webserver is running as you and have access to your networked drives etc. IIS on the other hand uses a different user account and doesn't share your user profile including your ClearCase views etc. That may explain your problems.
I found the problem and a resolution to this. The problem is that ClearCase is using the process user for authentication whereas the shared drive access mentioned in the original question is using the thread user.
The reason for this is the when accessing ClearCase it spawns off a new process - and child processes always use the parents process security context and not the current thread's.
The way around this was to run the web application within its own application pool which is running as a user with rights to access ClearCase. An inflation of rights beyond what should be really necessary however it did the trick.