ImageResizer not working with virtual directories - imageresizer

I am using the ImageResizer successfully on other areas of my site where the images are being served from a folder within the application (both .jpg?width=100 & .jpg.ashx?width=100 work), but when I try images from a virtual directory located on the local machine, I can only get resizing to work if I specify the image page using the "jpg.ashx?width=100" method.
The site's application pool is using NetworkService identity and the virtual folder has pass-through authentication enabled. I've granted Modify permissions to NetworkService on the virtual folder too hoping that would help.
I am using IIS 7.5 in Classic Mode and the resizer diagnostics page doesn't show any issues.
Does anyone have ideas on why this may be happening? Any help would be appreciated.
Thanks!

Classic Mode requires the .ashx syntax, since ASP.NET doesn't see static file requests.
If you're seeing different behavior within the same site on the same host, then your virtual folder is probably NOT a virtual folder, it's likely a sub-application.

Related

Virtual Directories not working in ColdFusion Builder 2016

I'm trying to set up virtual directories through the built-in Apache Tomcat 8 server using the ColdFusion Builder 2016 interface, however to my surprise this simply does not work, yet according to the documentation it should.
The only thing that I've modified was the web root directly in the server.xml file.
That said the website runs correctly, except when trying to reference a resource from a virtual directory which simply returns HTTP Status 404.
Web Structure
ColdFusion Builder Interface
The process when using the interface is as simple as:
Creating a virtual host;
Clicking the "Virtual Directory" button and setting up the directories; and
Applying the changes and restart the local server.
Ultimately this should allow me to navigate to the files (CSS, JS, Images) directly through the web browser.
Could I be missing a specific setting in a configuration file due to manually changing the web root? If not what am I missing?

ImageResizer triggering login redirect on a virtual directory

I am using Image resizer just fine in other areas of my site to resize local images, but when trying to resize an image that is in a virtual directory, I am getting the login screen. (Logging in does not change anything) If I add the '.ashx' extension, I get the same result.
The site is hosted on IIS 10 (integrated mode), with the appPool identity granted modify permissions on the site directory. The virtual directory is using a network user that has modify permissions on the network folder. The debug output does not show any errors -- I've posted the gist [here]
I can access images in the virtual directory without a resizing querystring (image.jpg instead of image.jpg?width=100) and the images are served up normally. However, as soon as I add a resizing command to the querystring, I get the login screen.
Any suggestions on what I am doing wrong?
Thanks,
Nathanael had the solution above in the comments -- to solve the issue, I created a network user and granted modify privileges on the shared network folder to that user. I then set that same user as the application pool identity. Thanks for the help Nathanael!

Virtual Directory to navigate to http://localhost/MyWebsite instead of http://localhost:8080

I have deployed an ASP.NET MVC 4 application to a new site I have created in IIS 7.5, which I have bound to port 8080. I can reach it by navigating to http://localhost:8080, but I want to reach it via http://localhost/MyWebsite.
I have added a Virtual Directory under my website, which points to "C:\inetput\wwwroot\MyWebsite\". However, when I navigate to http://localhost/MyWebsite, I am presented with a configuration error:
"It is an error to use a section registered as
allowDefinition='MachineToApplication' beyond application level. This
error can be caused by a virtual directory not being configured as an
application in IIS."
Here is what my IIS hierarchy looks like (this is a demo since I have no internet access on the server I am working on).
I have two questions:
Why am I getting this error?
Is this the best way to go about achieving what I want? It seems messy to have the list of files and folders underneath the website and then again underneath the Virtual Directory. If there is better practice then please tell!
Virtual Directories cannot execute scripts, reason why you are getting that error. You need to make your MyWebsite folder an Application. Also, you don't necessarily have to create a separate website for your website, you can use the Default Web Site and create an application MyWebsite in there (it might be less confusing maybe?).

What's the right way to add ImageResizer to an IIS virtual folder

My ASP.NET contains an IIS virtual folder that points to static images (so that the HTTP requests serving up these images do not even touch my app).
To web clients consuming my site at http://<server>/myAppRoot:
Page1.aspx
Page2.aspx
images/MyAppLogo.png
static/file1.png <-- IIS virtual folder "static" points to D:\someOtherPath
static/file2.png
On the server filesystem at C:\somePath\myAppRoot:
Global.asax
Page1.aspx
Page2.aspx
Web.config
bin\MyAppAssembly.dll
bin\ImageResizer.dll
images\MyAppLogo.png
And elsewhere on the server live all the static images at D:\someOtherPath:
file1.png
file2.png
I can add ImageResizer to the ASP.NET bin folder, along side my own assemblies, and add the <resizer> tag to Web.config, ImageResizer will run and process any request from my actual app folder. I can use all the ImageResizer stunts to make MyAppLogo.png dance.
But ImageResizer won't recognize intercept any requests for the /static/ virtual folder (which is the folder containing tons of uploaded images that I want small thumbnails for on the fly).
How do I configure ImageResizer to process the /static/ virtual folder?
I should add that /static/ is added by our installer, completely outside of our app, and is not a <location> tag inside my app's Web.config.
Any suggestions on how to configure ImageResizer to process the /static/ IIS virtual folder?
The way I understand it, ImageResizer should work with IIS virtual path providers.
However, there is the VirtualFolder plugin, which is available for free. See http://imageresizing.net/plugins/virtualfolder . Note the caveat:
IIS Virtual Folders perform better, however, so this plugin should only be used for testing, development, or as a last resort.
I have no personal experience on the plugin but the configuration seems easy; you'll just need to map virtual paths to physical paths like this:
<add name="VirtualFolder" virtualPath="~/static/" physicalPath="D:\someOtherPath" vpp="false "/>
Well, testing the access attempts to the myAppRoot/static/* paths directly on the webserver revealed a much more detailed IIS error (403.1 Forbidden).
The /static/ folder had been previously configured with "Read" access, when it needed "Script" access.
Solution:
Modify the <handlers> of <system.webServer> in D:\someOtherPath\Web.config to <handlers accessPolicy="Script" />

Virtual Directory pointing to UNC share

I have an app that uploads documents to the server through the standard
When sent my application to the production server, I found out that they had the server load balanced. My solution to this was to place the upload directory into a network share and then create a virtual directory pointing to the share.
I have set permissions on the share and the file itself, but I keep getting "access denied" whenever I try to upload a document.
Where could I be missing permissions? Is it possible that IUSR needs to have access to the share?
Thanks.
FYI,
The answer to this solution for me was to setup temporary impersonation with a user account that had access to the share, the folder and the virtual directory.
Here's a link to the code that worked for me:
http://support.microsoft.com/kb/306158#4
I hope your site use anonymous access. Otherwise you will have a painful experience.
If it is so ( anonymous acess), then: The IUSR is a local user on the production servers and not a domain user. So it don't have access the the share. You will have to change that to a domain user ( in the site configuration and not on the application pool). And make sure that the application pool run on a network service ( this is the default ) and it should work.
Chances are that whatever your ASP.Net process is running as does not have access to the share.
So chances are you need to set up an IIS6 application pool to run as a domain user and have that domain user have access rights to the file share.
Don't forget to aspnet_regiis -ga {domainuser} so that the domain user can actually run asp.net applications.