MVC Storing image on network drive - google-chrome

I have a MVC application, in which I am trying to store a image on a network drive and retrieve the same. The application works fine on IE but fails on chrome, upon spending some good amount of time on net I found that this is because of security reasons i.e. Chorme and Firefox prevent retrieving resource from network path and some suggested I have come across was setting UNC path- but even that did not work.
Below are some file path I configured on web.config
<add key="ImageLocation" value="\\user-one\share\UploadImages\" />
UNC Path.
<add key="ImageLocation" value="file\\user-one\share\UploadImages\" />
I would appreciate if someone has come across this issue and have any alternate solution or suggestion to address this.
Regards,
HSR.

Related

Api works on local but not in production (Django Rest + Flutter)

This is my first question in stackoverflow. I have always found answers searching but this time...
I have 2 json generated by Django Rest Framework, both of them have just strings...
The only thing i do is changing the local server urls for the production urls in my Flutter code.
While using local urls, i can display the data from both of them correctly inside a Flutter App.
While using production urls, only one is shown in the App and the other won't. Both jsons are rendered correctly in their production urls, i compared them with the local jsons urls and there is no difference at all.
Well, it is not really a question because i don't really know what to ask... just hoping some ideas... thanks.
make sure the AndroidManifest.xml includes the internet permission
if not, add this between <Manifest> and <Application>
<uses-permission android:name="android.permission.INTERNET" /><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

.net6.0 API Empty Json body on large requests

Good morning,
I have a bit of an odd one I am scratching my head about at the moment, and was wondering if anyone faced something similar in the past. I am working on a rest API in .net6.0, and we have noticed failures on response which are approximately larger than 200MB of JSON (whether an API should return packets this large is a different topic, and we are having discussions about this too).
The main symptom is that the calls come back as a 200, so successful, and I can also see from the API logs that all the processing was completed, however the response body is empty. I can replicate this pointing different clients to the API (e.g. Postman). There is nothing helpful in either the Event Viewer nor the IIS logs.
What I have tried, unsuccessfully:
The API is hosted on a Windows Server 2012 (IIS 8.5) machine, but I also machine to replicate this on a Windows Server 2019 (IIS 10.5) one, so not a compatibility version in terms of IIS version.
Tried adding the following to the web.config file as it resolved a similar thing I had in an older framework:
<httpRuntime maxRequestLength="2147483647" executionTimeout="10800" />
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648" />
<!-- maxAllowedContentLength is in bytes -->
</requestFiltering>
</security>
Increased the Response buffering limit in IIS's ASP configuration.
None of those managed to resolve my issue.
One thing I did notice though, is that if I switch the settings to use Kestrel, updating the web.config file to use OutOfProcess, my problem disappears.
While I don't want to use Kestrel, this leads me to believe it's on the IIS front.
Would anyone have seen something like this before and have an idea of what I might be missing? Any advice really appreciated on this one.
Thank you,
Alex.

can phpMyAdmin MIME point to local file and thumbnail? file:\\

I am trying to get phpMyAdmin to show the image/link for a field that has a local path.
For example, the path of my picture is Z:/Koala.jpg.
I've setup MIME type: plain/txt and the Browser Transformation: txt/plain imagelink.
It works for online images where the picture has http:// but not for files stored on my local hard drive.
It actually shows the Z:/Koala.jpg as a link and underlined, but it won't open anything when I click. phpMyAdmin appends file:\\ but I've tried both ways and no luck. Multiple browsers too.
PS Z:/ is a mapped network drive of my Network attached storage. But it doesn't work even if I use C:/.....
What you're trying to do isn't possible. Security restrictions in modern web browsers prohibit web sites from loading resources from the local filesystem (e.g, file://).

How would I go about creating a custom protocol that would always open an address with a specific browser?

Okay, so I'm a student programmer in my college's IT department, and I'm doing browser compatibility for a web form my boss wrote. I need the user to be able to open a local file from a shared drive with a single click.
The problem is that Firefox and Chrome don't allow that for security reasons. Thus, I'm trying to write a custom protocol of my own to open an address in Internet Explorer regardless of the browser being used.
Can anyone help me with this? I'd also be willing to try an alternative solution to the problem.
The below worked for me, is this what you mean?
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\foo]
#="URL: foo Protocol"
"URL Protocol"=""
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\foo\DefaultIcon]
#="C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe"
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\foo\shell]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\foo\shell\open]
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\foo\shell\open\command]
#="C:\\Program Files (x86)\\Internet Explorer\\iexplore.exe \"%1\""
Just to note, I'm running Win7Pro, so you may have to move around file path(s) to conform to your environment.
And if that doesn't work, create a proxy between the protocol and the browser, pass the argument(s) from foo:// to that, parse what's necessary, then hand it off to IE using start iexplorer.exe "args".
I'm unsure whether I understand your question, if it is how do I open local files using chrome/firefox, this is your anwser:
First a disclaimer, I have never done this and cannot vouch for the accuracy of my response
IE
Microsoft's security model is pretty fail so you can go right ahead and open these files
FireFox
Some quick googling found that Firefox can do this after either editing prefs.js as outlined here or installing an addon called LocalLink
Chrome
Practically impossible due to its security, until now when locallink was ported to chrome.

Workaround for href="file://///..." in Firefox

On an intranet site, let's say I want to link to a file on a share using UNC, at:
\\servername\foldername\filename.rtf
It seems the correct way to do this is with markup like this:
filename.rtf
That's five slashes - two for the protocol, one to indicate the root of the file system, then two more to indicate the start of the server name.
This works fine in IE7, but in Firefox 3.6 it will only work if the html is from a local file. I can't get it to work when the file comes from a web server. The link is "dead" - clicking on it does nothing.
Is there a workaround for this in Firefox? Those two browsers should be all I need to worry about for now.
Since this is obviously a feature of Firefox, not a bug, can someone explain what the benefit is to preventing this type of link?
This question has been asked at least twice before, but I was unable to find those posts before posting my own (sorry):
Open a direct file on the hard drive from firefox (file:///)
Firefox Links to local or network pages do not work
Here is a summary of answers from all three posts:
Use WebDAV — this is the best solution for me, although much more involved than I had anticipated.
Use http:// instead of file:///// — this will serve up a copy of the document that the user cannot edit and save.
Edit user.js on the client as described here — this worked for me in Firefox 3.6.15, but without access to client machines, it's not a solution.
In Firefox, use about:config, change the Security.fileuri.strict_origin_policy setting to false — this doesn't work for me in 3.6.15. Other users on [SO] have also reported that it doesn't work.
Use the locallinks Firefox extension — this sets the Security.fileuri.strict_origin_policy to true for you, and appears to have no other effect.
Read the file server-side and send it as the response — this presents the same problem as simply configuring your web server to use http://.
Browsers like Firefox refuse to open the file:// link when the parent HTML page itself is served using a different protocol like http://.
Your best bet is to configure your webserver to provide the network mapped file as a web resource so that it can be accessed by http:// from the same server instead of by file://.
Since it's unclear which webserver you're using, I can't go in detail as to how to achieve this.
In Firefox to Open File:\\\\\yourFileServer\docs\doc.txt for example you need to turn on some options in Firefox configuration:
user_pref("capability.policy.policynames", "localfilelinks");
user_pref("capability.policy.localfilelinks.sites", "http://yourServer1.companyname.com http://yourServer2.companyname.com");
user_pref("capability.policy.localfilelinks.checkloaduri.enabled", "allAccess");
As it turns out, I was unaware that Firefox had this limitation/feature. I can sympathize with the feature, as it prevents a user from unwittingly accessing the local file system. Fortunately, there are useful alternatives that can provide a similar user experience while sticking to the HTTP protocol.
One alternative to accessing content via UNC paths is to publish your content using the WebDAV protocol. Some content managements systems, such as MS SharePoint, use WebDAV to provide access to documents and pages. As far as the end-user experience is concerned, it looks and feels just like accessing network files with a UNC path; however, all file interactions are performed over HTTP.
It might require a modest change in your file access philosophy, so I suggest you read about the WebDAV protocol, configuration, and permission management as it relates to your specific server technology.
Here are a few links that may be helpful if you are interested in learning more about configuring and using WebDAV on a few leading HTTP servers:
Apache Module mod_dav
IIS 7.0 WebDAV Extension
Configuring WebDAV Server in IIS 7, 6, 5
Add your own policy, open configuration "about:config" in the location bar and add three new entries:
capability.policy.policynames MyPolicy
capability.policy.MyPolicy.sites http://localhost
capability.policy.MyPolicy.checkloaduri.enabled allAccess
Replace http://localhost with your website.
Works with Firefox 70.0.
I don't know if this will work, but give it a shot! Old article, but potentially still useful.
http://www.techlifeweb.com/firefox/2006/07/how-to-open-file-links-in-firefox-15.html