question

LKA116-9972 avatar image
0 Votes"
LKA116-9972 asked cooldadtx commented

IIS web app file download

Have IIS 10 for our VM - one application prompts to download the Access File. The other does not. Both have the MIME type set locally to application/octet-stream for extension .mdb

I have placed identical code (.cshtml) ( with a static file path to the same file on our server ). The link looks identical - but one prompts me to download the other doesnt ....

Clues ?

Thanks

windows-server-iis
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

 <p>...MycAcess.MDB</p>
 <a href ="file:///\\Myserver\folder\folder\folder\folder\MyAccess.MDB">Test for DownLoad sample file</a>
 <p>


This is from viewing source - only server , paths and file name are obfuscated...
All looks identical when clicked on ,,,, just one prompts for permissson and downloads the other just shows path and doesnt invoke anything



0 Votes 0 ·

So you're just using a file share path? So this is an internal app on your network. You're URL doesn't appear correct. There are a couple of allowed formats that should work:

file:///server/folder/...
file://///server/folder/...

Note that browsers may identify this as a security hole and prevent it from working. You need to check your security settings in the browser.

0 Votes 0 ·
cooldadtx avatar image
0 Votes"
cooldadtx answered

The cshtml would likely be calling back to a controller to download the file. Therefore the problem would need to be on the controller side. You can easily test this by foregoing the HTML and use CURL or Postman to attempt to download the file directly. If it works then the server side code is fine. Can you post the code that isn't working? Have you tried setting a breakpoint in the controller code to confirm it is even hitting the correct controller action and trying to download the file.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

SamWu-MSFT avatar image
0 Votes"
SamWu-MSFT answered

Hi @LKA116-9972

You can try to add the following lines to that section in your web.config, for example your web.config should be similar to this:

 <system.webServer>
     <security>
       <requestFiltering>
         <fileExtensions allowUnlisted="true" >
           <remove fileExtension=".mdb" />
           <add fileExtension=".mdb" allowed="true"/>
         </fileExtensions>
      </requestFiltering>
    </security>
  </system.webServer>

If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

LKA116-9972 avatar image
0 Votes"
LKA116-9972 answered cooldadtx commented

Sorry for late check back. I republished this code to a new app with a small change to the Application name. The prompt triggered. I then called the app from another website/application in our company. When called from another site, the prompts no longer show.

The first web site seemed to block or over-ride ( MIME setting ).

I then added the changes to the web.config file above. I could still get the prompt when I called the app site directly, but NOT when called from another site. Yet the first site allows download. So no change

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

You're putting a URL in an HTML page to a file server. There is nothing on the web server side that would matter for this as no web server calls are needed. This is literally just the browser accessing a URL. You could replicate this issue by putting that exact same URL into a regular HTML page (no web app at all) and I suspect you'd have the same issue.

However browsers run in a sandbox so I suspect the issue is that your browser doesn't trust your site and therefore doesn't like the file reference. It might work in one case because the URL is considered intranet or safe but I'd be guessing here. Have you checked your browser settings to ensure it is not blocking the URL because of security?

0 Votes 0 ·