Excel file download not working on server - asp.net-mvc

I have a strange problem.
we have a website, from where the user can download excel files. In my local system the excel file is downloading ok, but in the life site the excel download it is not working.
I have observed that if I open remotely the server machine, teh excel download suddenly works on the life site too, but if I close the remote it does not work.
I think that it is a permission issue, but I could not realize yet, what can be the problem.
I have tried these settings:
Navigate to Component Services > Computers > My Computer > DCOM Config
Locate the MS application giving you trouble (eg: “Microsoft Excel Application” for Excel or “Microsoft Word 97 – 2003 Document” for Word)
Right click > Properties
On the security tab: Select Customize under Launch and Activation Permissions and click Edit…
Add the account under which the site is running (eg: Network Service) and assign Local Launch & Local Activation permissions
this is what I have founded on the net, but it is not working...
Any help is appreciated.

Add Content-Disposition header in your response
var cd = new System.Net.Mime.ContentDisposition
{
FileName = "MyFile.xlsx",
Inline = false,
};
Response.AppendHeader("Content-Disposition", cd.ToString());

Related

File Explorer - Open in MS Edge?

Good day. I have a requirement to move from IE 11 to MS Edge on our systems, with all functionality as well. Currently, users will log into the computer, IE will launch with a local HTML file - User Dashboard, and then select which button on the page they want to use. Some of these buttons are linked to PDF files, some open File Explorer so that it opens their 'working directory' and/or file explorer to another directory on the machine for them to work in. They also run .lnk / .ps1 files. Works like a charm.
I was able to get about 80% of the functionality working using the Edge GPO template but now the only thing missing is opening file explorer for them to use the above situations. Currently when they click on the button on the page - file:/// - it opens up a new tab that displays the directory it is linked to. Unfortunately they are not able to run .lnk / .ps1 / .bat files. When selected, they open up in a new tab with the code displayed.
Is there anyway to run a program from Edge? I've already set the following in the GPO:
LGPO - Administrative Template -> MS Edge -> Allow launching of local files in internet explorer mode -> Enabled (default -> Not Configured)
LGPO - Administrative Template -> MS Edge ->< Configure Internet Explorer Integration -> Enabled -> IE Mode (default - Not Configured)
LGPO - Administrative Template -> MS Edge -> Open Local Files in Internet Explorer Mode file extensions allowed -> Enabled - "*" (default - Not Configured)
Hope this makes sense. Thanks in advance ...
Is there anyway to run a program from Edge?
Generally no, Edge used to be able to run epub files but even that feature is now removed.
Basically you can run any file type that is readable within Edge so txt or xml or htm or svg or mp4 etc.
When browsing local system in reader mode you can navigate up and down folders** local or on server and click any readable file type, however LNK files will behave in different ways.
LNK files that invoke an svg or txt or other Edge text safe readable object will open that readable bat cmd wsh ps1 file in a tab if necessary.
LNK files that call an executable such as notepad calc cmd or anything like a .hta runtime file count as not readable and are treated as requiring a security response, so will invoke an extra security step asking if you wish to download a copy.
You can download a copy of notepad.exe or cmd.exe but it will then run raw so runs outside EDGE and thus a copy of CMD.exe will simply open the console or a copy of notepad will open with a blank page. Only a copy of a stub.exe that does not need arguments would be useful.
** A zip folder normally operable in File Explorer counts as a downloadable security risk inside Edge.

"Access to D:home\site\wwwroot is denied" ASP.NET MVC WebApp hosted on Azure

I've been trying to open an excel file in my ASP.NET MVC project (I use Syncfusion library for that).
For some reason, when I publish the webapp with Visual Studio, I get the
"Access to the path 'D:\home\site\wwwroot' is denied."
error.
The file is correctly uploaded to the webserver (I can download it just fine when I input the path in the browser). I've looked into this question, but there is no WEBSITE_RUN_FROM_PACKAGE setting in my azure webapp. I went into Kudu, opened up the console and ran
icacls "D:\home\site\wwwroot"
which gave this output
D:\home\site\wwwroot Everyone:(I)(OI)(CI)(M,DC)
BUILTIN\Administrators:(I)(OI)(CI)(F)
So, with my little understanding of acls, it seems that Everyone has Modify permission to this folder.
Which means that I'm at a loss as to what to do.
Code:
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
application.EnablePartialTrustCode = true;
IWorkbook workbook = application.Workbooks.Create(1);
var dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
dir = dir.Replace("file:\\", "");
dir = dir.Replace("\\bin", "");
var dirXlsx = "\\Areas\\Stampe\\Content\\Excel\\RapportoProvaMare(version1).xlsx";
FileStream s = File.OpenRead(dir + dirXlsx);
IWorkbook source = excelEngine.Excel.Workbooks.Open(s);
I don't think the Syncfusion code has anything to do with the issue, I'm just reporting it for completeness.
Anybody have an idea as to what the issue could be?
EDIT: To be more specific, I'm publishing the code via Visual Studio, with the excel file in a folder of the website (just like you would do for an image). All the test I've made to the dir variable have been tested on the Azure environment (we have a duplicate test environment). I just need to read the excel file from the local website folder and process it before sending it to the user.
Please use %HOME% for persistent file storage or %TMP% for temporal storage
You can create a %HOME% environment variable in your local computer for test purposes.

Wampserver 2.4 cannot find .mo file

I am trying to do this:
I created an isapi dll. The DLL searches a database on the server (this is not a
web domain, it is a Windows 8 PC that is accessed remotely via its ip).
Basically the (remote) user enters a URL on its browser (xxxx.xxx.xxxx.x.dllname.dll)
and the dll should read data from a database and produce an html page to show the results
on the browser.
Sorry it's the first time I post to stackoverflow and I deleted
my question in the Edit post:
The question was:
I installed Wampserver 2.4 on Windows xp I
I try to run a DLL that I wrote by clicking on "www directory"
and then double clicked on my DLL.
I get a window that shows a caption
"This will append the following translations to your executable file"
and then in the check box list below it shows 1 line
No translations (.mo files) found"
and the ok button stays grayed.
What is happening?
What is the "translation" it talks about?
Why do I need the translation? why Wampserver does not go on without translating? (whatever it means).

html link to client side file

I am developing in ASP.net a web application which among other things should list documents available on a remote server.
this is for a very restricted number of users for which we can control the end PC.
What i need is the end user to click on a hyperlink and the file would open directly in words or excel for edition and save direct to remote server.
Files will also be available on a very common cloud file sharing system with the "virtual drive" letter (x:)
google doc does give you a unique url for each file but when one click on the link it opens online not in the local Microsoft Word. these is a plug in for office but document have to be open from word not from the webapp.
So the idea would be to create a windows explorer link to the file to open "file.lnk".
and set the browser to open lnk extensions with Explorer.
link
where test.lnk is an explorer link to the targeted file on the virtual drive.
this sound a bit dodgy, i agree, as it only works on windows.
this actual works ok as long as the htlm file is run on the local machine ( d:\app.htlm) but does not work when the html file is served on a remote web server ( mydomain.com/app.html)
Question:
why is the link on client side not served from the remote web server?
is there a simple implementation of editing MS office documents opened from the web browser without monster application like sharepoint or Alfresco?

Open a file that is on a file server from a webpage?

I am working on an internal application. We have a website that displays all our SSRS reports for a group of work. I have been asked to see if I can link all the files (pdf, word, excel) for the group of work. These files are stored on a file server that users viewing the reports have access to. Each group has its own group of reports and shared files.
Is it possible to open the files (without downloading them) from a webpage? Meaning that they file is opened from the file server? I don't want people to download a copy of the file.
I am pretty sure this can work with IE because sharepoint does it. However, other browsers may have an issue.
EDIT: What I would like is to have a web page with links to the files. When they click on a link (say for a word doc), word will open the file that resides on the file server. Without out a local copy downloaded from the network share.
EDIT2: Please note, I know what I am asking is probably not possible in all browsers. I am more or less just making sure. It seems possible in IE using activeX, but out side of that browsers do a good job at keeping processes inside a sandbox.
3 options. Remember this is for an internal website.
link to the share using file://. This will have the side affect of downloading the file to be viewed. As long as user clicks open every time it should not be a big deal.
Use JavaScript and activeX to open word (excel, reader, ect) passing in the file path as a command line arguments. This works only in IE and in win7 (probably vista) user will get a pop up asking if it is ok for the activeX control to run.
Create a new protocol. openfile://. This would be set up to run an application that is installed on the client machine which would open the file. Since it is internal, the application could be installed on the machines without issues. This also requires a registry change.
I haven't picked one as this change is still being looked into but i figure I would update this in case someone runs into something similar.

Resources