web.config error when trying to display an image - asp.net

I ran into an interesting error when trying to load an image and I was wondering if anyone else has experienced this or even better know how to fix it.
So I have a virtual Directory setup through IIS 7.5 referencing a network share. I am using valid credentials and have verified that I can connect to the share using these credentials.
When I try to navigate to the image I get the following error:
Parser Error Message: An error occurred loading a configuration file: Invalid file name for file monitoring: '\\share2\EmployeePhoneListPhotos$\web.config'. Common reasons for failure include:
- The filename is not a valid Win32 file name.
- The filename is not an absolute path.
- The filename contains wildcard characters.
- The file specified is a directory.
- Access denied.
Now there is NO web.config file in this share folder, however it's just displaying a .jpg image from here so there should be no need for one.
Does anyone have any idea why it would even look for a web.config file in a folder that only had images?

Related

.NET Core - same project running under iis express on different drive

I recently bought a new computer. I moved the drives from my old computer to the new one, installed everything I needed to and opened my project. Now I'm trying to run my project in IIS express but it displaying an error specifying an html output as log file.
When I look at the html problem, it's a 500 error message generated by what looks likes an IIS page. It's saying that the config file cannot be found:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid
Config File
\\?\F:\Development\MyProject\API\web.config
When I switched to the new machine drive letters were changed, so the code I'm running is no longet on drive F like in the message above - it's now on a different drive. I've looked in my code - I have no reference anywhere to a specific path.
I've tried to do clean and rebuild but it doesn't work.
If I look inside files for the path I see that the DLLs are compiled with PDB file path inside them. Why is that? And what happens later on on production?
Also, how do I fix this problem? why does it keeps looking for old location?
I'm fairly sure the IIS Express metabase still has the old path configured for this site. Please see the following answer for how to locate the metabase file (it's usually here: \Documents\IISExpress\config\applicationhost.config):
Where is the IIS Express configuration / metabase file found?
I'm not sure what the most correct way is to correct the problem, but you should be able to manually edit this file and update the "physicalPath" attribute for your site to the correct path to resolve this problem.
I don't know the exact cause of my problem, but the solution was to delete all bin directories from all project folders and re-compile.
To delete the bin directory from all my project I wrote the following PowerShell script:
Get-ChildItem -Path . -Filter *bin* –Recurse | Remove-Item -Recurse -Confirm

strange issue when uploading file via asp.net, vs manually via FTP

I have a form in ASP.Net MVC, which allows you to upload a file. The file is saved to a location on the server. For example, if the domain is www.test-domain.com, and the local path is c:\websites\test-domain.com\, the image is stored in /uploads/File/image.jpg.
When I try to access this url http://www.test-domain.com/uploads/File/image.jpg, I get redirected to the forms loginUrl="XXXX" path in web.config. To test, I removed the web.config entirely, and accessed the file. This time round, I get a 401 - Unauthorized: Access is denied due to invalid credentials.
I then uploaded another file via FTP this time, to http://www.test-domain.com/uploads/File/image2.jpg. This one can be accessed without any problem. I even tried download image.jpg as saved via Asp.Net, delete the file on server and re-upload the same exact file by FTP and it worked again!
It seems by FTP is working, while via Asp.Net somehow there are some access / authorisation requirement. I do have authentication set in Asp.Net, but I removed the entire web.config file, and I still got an error.
Any ideas?
I've found out why this was happening, though it is totally unrelated to what I thought it was in the beginning. I am uploading an image and resizing it. I've looked further in the code, and for some reason I was creating an image in the temporary windows folder, and then moving it to the actual location using File.Move.
It seems that the security permissions created are different, than if I had to create the file directly in the final folder. I've updated the code to create the image directly in the actual folder, and this is working fine.
Reference: http://blogs.msdn.com/b/oldnewthing/archive/2006/08/24/717181.aspx

Unable to find template in prod

I just uploaded my application to my webspace, and cleared the cache via ssh. But in the prod environment my log file shows me an exception:
InvalidArgumentException: Unable to find template "Project:News:overview.html.twig". (uncaught exception) at /path/to/my/project/vendor/symfony/symfony/src/Symfony/Bridge/Twig/TwigEngine.php line 123
Do you have any ideas what I can do?
In most cases the problem is, that windows is not case sensitive and linux is. So check your files and the case sensitivity of your files and folders.

Downloading file using webclient results in "Access to the path denied is denied"

i have button, on a click of which i want to download the file on the local pc, i am using webclient.downloadfile(), but i am getting the below error:
Access to the path 'C:\Windows\SysWOW64\inetsrv\ms-banner.gif' is denied.
i am using below code to download file:
WebClient client = new WebClient();
client.DownloadFile(new Uri("http://www.contoso.com/library/homepage/images/ms-banner.gif"), "ms-banner.gif");
i dont understand why its fetching the file from local server, as i have already stated the remote uri
It's fetching the file from the remote server but trying to save it in the current directory because you have only specified a relative filename as second argument: "ms-banner.gif". And it seems that the account you are running your application under doesn't have permission to write to the current working directory which happens to be C:\Windows\SysWOW64\inetsrv.
So you have basically 2 possibilities:
Modify the account you are running your application under and grant it permissions to write to this directory
Specify another location (as an absolute path) to save the file to where the account you are running your application under has write permissions.
contoso.com redirects to microsoft.com... the path you have there in the URL does not exist and you won't be able to download it. I'm not sure why it's trying to go to your local machine, but have you tried some other image on some other website? Like http://i.cdn.turner.com/cnn/.e/img/3.0/global/header/hdr-main.gif for example?

Sandbox violation while accessing image files in Flex 4

I'm working on an image gallery application. Very frequently I'm getting Sandbox violation Error like Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.. Some times its raising by cleaning the project. Every time I'm using my application's backup and updating and then the error is raising. Though I'm accessing local image files, getting error. I'm using try-catch to catch the location but no use. How to get rid of this problem. Any help is appreciated.
If u Clean the project It Will remove all your
assets files in the bin-debug folder and it will be
recreated during the Build.Some times the build wont
creates the file properly i think that time you are
getting the error.
At most avoid cleaning.It may also happens by the
out dated flash player version.
It may also happens by the following ways,
incorrect path to the upload file script - check relative and absolute paths
a incorrect location for the files to be stored on the server specified inside server-side upload script - check path is correct and permissions are correct
file is too large so server rejects it - check max file size
there is no space on the server to save the file - check server hard drive space
your actionscript handler is going out of scope because it's declared locally,
etc - create a strong event listener or declare the file reference on the class
Check one of the option and Comment is must.
About loading local images. You should check and fix Flash Player trust file for your SWF as described here. Flash Builder done it automatically but who knows…
About problem with loading images in web it can be problem related to loading images from other domain which hasn't proper crossdomain.xml file. If so you should use some kind of proxy on your server.
If you're loading files from your own domain maybe this deployment checklist can help you. Also you can use some debugging proxy like Charles to see the real queries and responses.

Resources