Serving Excel File in MVC - asp.net-mvc

I'm in Internet Explorer 8, using MVC 1 and IIS 7.
I have an action on a controller which serves up an excel file.
I go to the action, a dialog pops up asking if I want to save or open the file, and I select open.
Then Excel makes a HEAD request to the server, followed by opening up a password prompt, then goes up a directory and makes an OPTIONS request, followed by 5 PROPFIND requests. Then if I cancel the password prompt, the excel document opens fine, and makes one final HEAD request to the original directory.
What is going on, and how do I stop it? Can I do something in global.asax or my web.config to mass block all these HEAD/OPTIONS/PROPFIND requests that excel is making? I don't have access to make changes to the web server.

This occurs in office documents where the microsoft programs try to open the file from the server itself. It then tries to authenticate and sends requests such as OPTIONS and PROPFIND to get the server type and tool available to do live editing and updating the local copy from the server, etc. Basically, its done for synchronization.
How do you stop it? no idea, probably have to look at the settings in your local excel tool.
How do you block specific requests in global.ascx? Whats the advantage of blocking it instead of just leaving it, its not like your application is using the request anyways. I'd like to see an answer for this though.

Related

File upload request in SharePoint Website using JMeter proxy recording and load test fails

I have issues recording a file upload request using JMeter Proxy. The file could be selected with the browse option and on pressing the SAVE or SUBMIT button the page refreshes and goes to the initial state.
I'm working on a load test project on a On-Premise SharePoint(v2013) Website with the following conditions,
Form-based authentication - Login and session cookies are working
correctly with JMeter.
Need to pass few dynamic variables like
__EVENTVALIDATION, __VIEWSTATE, __REQUESTDIGEST,
__VIEWSTATEGENERATOR which needs to be extracted using a RegEx
Extractor in JMeter from every request and needs to be passed to
subsequent POST request as parameters.
As a workaround, I used BlazeMeter Chrome Extension to record the file upload requests and all the API calls could be recorded correctly. But has issues replaying it in JMeter. The file upload fails again even though all the requests pass.
All the file upload POST requests passes with a success response code
of 200 and gives the same HTML content as the response, while replaying it in JMeter, but the file never gets uploaded.
If you are absolutely sure that you have HTTP Cookie Manager in place, correlation is working fine, etc. in order to record the file upload request it should be just enough to put the file to JMeter's "bin" folder so HTTP(S) Test Script Recorder could locate it.
Make sure the file is present in the JMeter's "bin" folder during replay as well. Check out Recording File Uploads with JMeter guide for more comprehensive explanation of the limitation.
If it doesn't help your JMeter configuration is still not correct. The common practice is capturing a request from a real browser and from JMeter using a sniffer tool like Fiddler or Wireshark. This way you will be able to inspect requests on a low level and identify the differences. Once you find out the cause - amend JMeter configuration so the request originating from JMeter would look exactly as the one which comes from the browser.

Running shell script form Ruby on Rails on the Client

I'd like to execute a shell script form my Rails app on the client.
In my case, I want to open a .odt file on the Client PC when he clicks on a link.
As for now, all I can do is run shell script on my server using e.g.
`libreoffice path_to_my_odt_file`.
In this case, I'm opening my file using LivreOffice on the Server.
Is there a way to execute this code on my Client from Rails?
If I try to run my app as it is, when I call the action that calls my script, the file is opened on my Server.
Thank you in advance.
As mentionned in the comments, running arbitrary shell scripts on the client from the http server would be a huge security flaw.
As long as your Rails server provides a download link with send_data (e.g. dynamically_generated_odt_file), the browser will ask if it should download the file or open it. If the user wants to avoid any extra interaction, there's the possibility to tick :
"Do this automatically for files like this from now on"
You might have to specify the MIME type, by adding
Mime::Type.register "application/vnd.oasis.opendocument.text", :odt
to config/initializers/mime_types.rb.

Pentaho 5.0.1 CE Adding folder to pentaho-solutions directory

How do I get a folder to appear in the browser after adding it to \pentaho-solutions in Pentaho 5.0.1 CE. The documentation I read does not seem to work with this new version.
1. Create a new directory in /pentaho/server/biserver-ee/pentaho-solutions/.
Use underscores instead of spaces in the solution directory name. Ensure that the directory has the appropriate user
and group ownership to be writable from the BI Platform.
2. Using an XML-aware text editor (or Design Studio), create a file named index.xmlin your new solution directory.
3. Copy the following text into the index.xml file, changing the content accordingly:
***<index>
<name>Example Solution</name>
<description>This solution contains examples I created while learning to
work with action sequences.</description>
<icon></icon>
<visible>true</visible>
<display-type>icons</display-type>
</index>***
4. Save the file and close the text editor.
5. Log into the Pentaho User Console as an administrator.
6. Refresh the solution repository cache by going to the Toolsmenu, then selecting the Refreshsubmenu, then
clicking on Repository Cache.
You now have a new solution directory. It will show up in all file dialogues in the Pentaho User Console as well as the
Solution Browser in the left pane.
Every time you add or edit an action sequence to your solution directory, you must refresh the repository cache as
explained above. Each user currently logged into the Pentaho User Console must also refresh their session cache; this
is best done by re-logging into the Pentaho User Console.
I am using Pentaho design studio to develop an xaction sequence script. I followed this procedure:
1. In Design Studio, go to the Filemenu, then select New, and click on Other...in the sub-menu.
The Newwindow will appear.
2. In the Newwindow, click the triangle next to Pentaho, select New Action Sequence Wizard, then click Next.
3. In the File namefield, type hello_world.xaction.
4. Select Hello Worldfrom the Templatedrop-down box, then click Finish.
The wizard will generate the new file and bring you back to the workbench.
5. Click on HelloWorldComponentin the Process Actionssection on the left.
The right side of the screen will change to show the options available for this action: Nameand Message. The
Name field controls the name of the component in the Process Actions list on the left; it doesn't do anything else of
note. The Message field contains the text that will appear on the screen when the action sequence is run. It is prepopulated with %quote, which is a token that represents a quote message in a nonexistent properties file. Pentaho
used to provide properties files for each example, but they have been removed from the standard Pentaho Business
Analytics distribution.
6. Replace the %quotewith a sufficiently inspiring message.
Alternatively, you could create a hello_world.propertiesfile and populate it with the appropriate messages and
tokens, but that has no advantage unless you intend to internationalize this action sequence.
7. Save the file.
You now have a working action sequence that prints a short text message: "Hello, World." plus whatever you typed into
the Message field. The first part of the message is determined by a message bundle packaged with the Pentaho Web
application archive.
To test the action sequence, use the Test tab if you are on Windows or OS X, or log into the Pentaho User Console and
run it from the Solution Browser.
Running the sample xaction fails with
Sorry. We really did try.
Something went wrong. Please try again
or contact your administrator.
I figure this is because pentaho cannot locate the xaction file as specified in the file path when I generate the url from within design studio. The folder I created within the solution directory does not appear in the browser directory list despite refreshing the cache. Any help?
With Version 5 the files and folders are no longer stored in "/pentaho/server/biserver-ee/pentaho-solutions/..."
It is stored now in a jackrabbit repository.
You can create folders and upload files in the user console.
I did mistake after starting biserver 5.2. Unexpectedly i deleted Public folder after configuring to jackrabbit. Now how do i create the folder so that i can see Public and Home Folders.
Sorry for getting back to this question some time later, just in case someone searches something related to Pentaho repositories management with no success, i hope this information can help.
Just to make things more clear, i'm using version 5.2.x and i'm supposing you want to create a new folder on the root directory of Browse Files screen, something that is not allowed on Pentaho5 CE Web Console.
The answers about repository management based on JackRabbit are correct, so the old way we used to configure new "solutions" folders doesn't work anymore. From version 5 on, Pentaho exposes an interesting REST api that allows you doing things not allowed in web console.
For instance, for creating a folder in root directory you should create a http REST PUT request against Pentaho Server (using tools like curl or if you appreciate Google Chrome, something like Advanced Rest Client, etc.) using the following URL:
http://localhost:8080/pentaho/api/repo/dirs/:new_directory_name?userid=admin&password=password
Pentaho repository directory REST api is documented here:
http://javadoc.pentaho.com/bi-platform500/webservice500/resource_DirectoryResource.html
It's worthy to spend some time reading REST API the documentation.

ASP.NET MVC 2: "The process cannot access the file <filename> because it is being used by another process."

I'm trying to use Controller.File to return a FilePathResult from a view in my ASP.NET MVC 2 project. I use it like this:
return File(pdfFilePath, "application/pdf", "foo.pdf");
However I keep getting this error in the yellow screen of death:
The process cannot access the file [the file path] because it is being used by another process.
This error usually comes up when you forget to close a file stream, but I figured that this should be taken care of by the ASP.NET MVC framework. This doesn't happen every time, but rather periodically. Sometimes I get the file just fine but then it just stops working. I am using the development server when testing this.
Any ideas?
Are you accessing the file prior to the line of code you provided? If so, how are you accessing it?
When accessing files, try to use the following to avoid file stream conflicts:
File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
The last enum FileShare.ReadWrite will allow other file streams to read and write to the file even if you have it open. Of course, it is better to remember to close your stream ASAP.
http://msdn.microsoft.com/en-us/library/y973b725.aspx
Do you have the file already open when you get this message?
If you do it might be Adobe locking the file.
The likeliest scenario is that something other than ASP.NET / IIS has the file open. Have you ensured that no other processes have a lock on the file when this error occurs?
If you have access to the server when the error happens, you can use a tool like Process Explorer to view what exactly is locking the file.
The locking can occur from within asp.net itself - as asp.net displays thread-agility, and as such it may be another thread from within the asp.net threadpool completing the request. This would be why you only see this issue intermittently.
Baddie's answer is basically the solution to your problem. As an aside, you might find other issues if you're using resources that contain state that are declared as threadstatic. If this is the case you might want to look at making use of CallContext.

How can step through an Action that is requested from JavaScript during execution?

There is this one action that is requested using javascript during the loading of a page, it takes over 25 seconds to resolve. Looking at the code makes me think there is a scaling issue, but I am wondering if there is any way I can step through the code during the request so I can see what is happening. I try clicking 'debug/start debugging' but it won't launch the proper URL (access to the site is subdomain based), and it will also not find certain dependencies. I am able to browse the site directly via URL locally after mapping a URL via my hosts file to localhost (127...) but the default url that pops up (localhost...) from debug does not work because it is not formatted properly.
Any ideas?
You can attach the debugger to your browser by selecting "Attach to process" under "Debug" menu.
In the past, at least with ASP.NET we have used tracing to debug issues. You will just need to enable it in the webconfig. If you use warn, the messages will show in red and be easier to spot.

Resources