I have a C# Windows form application and I need to open a a webpage that sends SAML off to a server with then does auth and redirects to the destination. Since the SAML I am writing/sending changes every time, I've been writing a simple file to the temp folder and opening it via the default browser. Internet Explorer doesn't like doing this and balks saying the content is blocked.
Is there any way I can, from a Windows form, open an external browser and write content to it?
I added
<!-- saved from url=(0016)http://localhost -->
in the html file I'm opening from the local temp folder and now IE opens it just fine.
Answer found from
Why does IE restrict the JavaScript files of local HTML pages?
Related
My asp.net web application is some kind of "document managment system" saving files in the file system of the server.
The stored files are shown in an asp:ListView control and are downloadable as HTTP- Download. But I also want to drag&drop them into another browser window to upload the draged file to an cloud storeage like dropbox or google drive oslt.
I did some research and I didn't find any solution for this problem. I don't know if this is even possible. Maybe someone has an idea how this could be done?
I am pretty sure you can't have a web application doing that for you because it involves having your web language interacting with your computer, to move a local file to another window or tab in the browser.
It would be similar to have Javascript accessing your local files without the user "help". That is not allowed.
Rather than doing that, why not connect to Google Drive or Dropbox API and make the upload yourself?
In the piece of code where you trigger the download, you could also trigger an upload to the desired service.
Here are the API Documentation for the mentioned services:
https://www.dropbox.com/developers/documentation/http/documentation#file_requests-create
https://developers.google.com/drive/api/v3/manage-uploads
Code:
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=pdfpage.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
The above code I used to allow a user of my web application to save a PDF generated on the server on his own device. The file is saving in as pdfpage.pdf on the desktop but I need to save this file in any folder. For example in E:\PDFs\pdfpage.pdf
Your question was wrong. I corrected part of it. Part of it is still wrong: you claim that the PDF is saved on the desktop. That may be true when you test it, but that is not true in general. For instance: if I would use your app, the PDF would be saved in the Downloads folder as defined in the settings of my browser.
There is no way you can define the download folder of a browser on the client by setting a parameter on the server.
There are some very simple reasons that explain that what you're asking for is impossible:
The server has no idea of the file structure on the client. For instance: there is no E: disk on my computer, so if you'd define the download folder as E:\PDFs\pdfpage.pdf, your web application wouldn't work.
It would be a serious security issue if a server were able to read the entire folder structure of the client machine in order to detect where to save a PDF file.
You are asking for something that is to be configured on the client side, in the browser of the end user. This can not be configured on the server side. For instance: I use Chrome, Firefox and Edge on my machine. I have defined different download folders for these different browsers. If I'd use your web app in one browser, it would download the PDF in a different folder depending on the browser I use.
Using ASP.NET and C# I'm looking for a way to open and edit an XML file via a web page. A user needs to go to a web page, open an xml file that is stored on their local machine, and then make edits and save it back locally.
I'm not sure how to open the file. Do I use the FileUpload control to let the user browse to the local file and then on a button event load the file into an XmlDocument? I tried this and could not get it to load the file. Once I have the file loaded I think I can build/edit nodes and data.
Not sure how to then save it back to an XML file on the local machine again.
If you want to do this in an ASP.NET web application I see the following process:
1) allow users to select a local file from their machine and then upload it on server and show its content in an edit box ( here you could also do nice things like allow drag and drop from windows explorer, there should be some JQuery / JS components ready out of the box to provide such feature );
2) once the file content is shown in the web page in a multi-line textbox ( ideally you would like to provide syntax coloring etc using specific web controls ), users can edit the content of it;
3) after changes are made, clicking on a save button the web page will start the download of the file from server to client, you can download the file with same name as it was uploaded if you stored that name somewhere, users will decide where to save the file.
This is the way I understand/see you can provide a functionality similar to what you have described from the top of my mind.
I am developing a web application in C#.net. I need to edit a file placed on the server in browser it self(Without downloading it on local machine) and when I save that file, the changes should be reflected in file. For this I want to use google API but I don't know how can I use this.
I want to do like below.
When I click on file name, it should open in browser.
When clicked on edit, it open in edit mode in browser using google doc.
When I save that file, the changes should be reflected in my file which is placed on company server.
How can I do all this thing with google doc API?
Install Google Drive on your server.
Edit the file in Google docs, let Google Drive sync it to the local hard drive.
It is not possible for HTTP protocol, because the basics system doesn;t support it. You can open the file but the file will be downloaded to your local machine in then it will open, you have to specify the MIME type in IIS.
You can use two ways to do a similar job done.
1 By Using FTP
2 Customized solution : Make a page put a text field and load the file (.cs) in it and with submit save it to the file back.
You can embed a google doc in Webpages. But the file would be accessed and saved on Google's servers and not your company server:
Wordpress allows you to do it. Potentially you can see if it possible to do it in a similar way:
http://en.support.wordpress.com/google-docs/
I am not sure if Google has an option of accessing docs from servers outside google's domain.
I am trying to write and application on windows where my application shud be prompted to open thru a browser link. how can I do that?
I don't know about second life, but I would register an file extension (like .MyApplication) with my application and create links to a .MyApplication-file on the web site. You an also encode special startup parameters inside that little file.