IIS7 Creating Virtual Directory to files on another server - asp.net

I am migrating some ASP.Net applications from IIS6 to IIS7 and all has gone well until now. I am trying to create several virtual directories on 1 server that will point to files on another server. In IIS6, all I had to do was make anonymous authentication use a user that had access to the files. In IIS7, I can't get it to work. I setup the virtual directory with the username and password but I get a 500.19 error "Cannot read configuration file due to insufficient permissions". I can't imagine that I really have to put a web.config in a directory that just contains images and no application files. If I click on the directory in IIS Manager, I get that error about the web.config file on anything that I click on such as the Authentication section. Also, writing to files from the virtual directory seems to work just fine so I don't think there is anyway that I have an access problem. I have given the directory access to the IIS_IUSR group.

When using a virtual directory that's pointed to a UNC share, go to advanced settings for the virtual directory, then choose a specific user account that has the appropriate rights to access the folder.
It works for my virtual directory in my asp.net app that is pointed to a UNC share on a remote server.

Related

Problem with IIS for creating file on Servers Folder

I have an AspNet App (Blazor) running on IIS server.
I would like to create a txt file on the server, but it doesn't work.
I changed the AppPool identity to a domain user accound and the directories in E: have full permissions for this account.
It works in VisualStudio IIS Express, but not in IIS.
Anyone here who can help me? A permission problem`?
C# Code for creating txt file:
File.WriteAllText(#"E:\Publish\Export\Test.txt", "Hello World");
If you want to save to a specific path, use MapPath (or Server.MapPath) to get the physical path corresponding to the application. Because by default the web server (IIS or local development server) will save to its working directory.
Also you need to make sure the account running IIS has read/write permissions to the directory you need to write to. If you're looking for user accounts, go to "Advanced Settings" under Application Pools and check what's set for "Identity".

IIS8 looking for web.config in virtual directory rather than app root

I have a Virtual Application in IIS8, http://localhost:80/application/, the files for which are located in C:\inetpub\wwwroot\application. There is a web.config file in the ~/application/ folder.
Under the application, I have a virtual directory, http://localhost:80/application/vdir/, the files for which are located in J:\virtual_directory.
When I try to access a file under the /vdir/ directory, I get HTTP Error 500.19 - Internal Server Error, it says it cannot read configuration file at \?\J:\virtual_directory\web.config
Why is it looking for the web.config file there, rather than C:\inetpub\wwwroot\application\web.config? I have never had this problem in IIS 7, this is my first time setting this up on a Windows 2012 server.
(Note: J: is mapped to a shared folder on the network. Not sure if that makes a difference?)
Okay, turns out I had to do two things:
Create the virtual directory using the UNC path (\\servername\sharedfolder) rather than the mapped drive letter
use a network account in the Physical Path Credentials under advanced settings rather than the default Pass-Through Authentication

Web configuration file being accessed in the wrong folder

I have deployed an asp.net website on a production server. It is working on my local but on the server I get this error:
An error occurred loading a configuration file: Failed to start
monitoring changes to
'E:\HostingSpaces\xxxxx\xxxxxx.xxxxxx.com\wwwroot\admin\web.config'
because access is denied
This looks to me that the app is looking for the web.config in the admin folder while it is obviously in the root.
How is this possible? How do I solve this problem?
IIS which is hosting ASP.NET is looking for a potential web.config file in every folder of your site, not just in the root folder.
This is because you may want to override certain settings for just one folder.
So you may have a web.config in admin but IIS hasn't got access to it, or IIS hasn't got access to the whole admin folder.
Check the permissions on that directory.
The problem is that the directory it has been deployed to does not have the correct read/write permissions for IIS to read the web.config.
Each website configured in IIS 6+ runs under a specific AppPool. That app pool runs under a specific user account, and it is that user account that needs read/write permissions to this directory.

Directory browsing without using a web.config on IIS 7.5

I'm trying to set up directory browsing for a file share to which my IIS server (7.5 on Windows 2008) has read-only access. I have tried configuring directory browsing using the IIS Manager, and also by directly editing the \Windows\system32\inetsrv\config\applicationHost.config file.
Despite my best efforts each time I attempt to view my virtual directory in IE I am met with a HTTP Error 500.19 (Cannot read configuration file) exception. It appears that IIS is attempting to locate a web.config file in the physical file share (which obviously doesn't exist).
Given that my file share will only ever be read-only, is there any way to configure directory browsing on my virtual directory without the requirement for a web.config file in the physical directory?
After spending considerable time on this I finally conceded to the HTTP 500.19 error. Despite my best efforts to convince it otherwise, IIS insisted on the web.config being present in the file share.
I ended up writing my own file system wrapper which essentially produced the same output as the default directory browser, and then deployed it with a dedicated service account with read access.

The requested page cannot be accessed because the related configuration data for the page is invalid

I am getting this error when I try to run an ASP.NET application without a web.config file.
The requested page cannot be accessed because the related configuration data for the page is invalid
as I read, we can run .NET applications without web config files, but when I tried it is giving me the error. I am using iis 7 on windows 7 machine.
When I create the application virtual directory inside inetpub/wwwroot it works fine. Why doesn't the other directory location?
One reason could be the version of .NET framework (on IIS or application pool level) is different from the application one.
Another reason could be if there are modules used in your web.config which the current configuration of IIS doesn't recognize. E.g. URL rewrite or other optional modules, which you have to explicitly enable before using.
This can be a reason:
If there is no Web.config file in the
UNC directory, IIS 7.0 uses the rules
that are defined for the parent
directory. For the Web content to be
served in this scenario, the
worker-process identity must have
access to the whole content directory.
Otherwise, the Web request is
rejected.
Details here.
You need to set permission for your Website folder or copy them to wwwroot folder.
If you choose to set permission, there are two ways:
Right click on Your Website folder, or
Right click to Your Website in IIS
Then select Edit permission and Add a permission (IUSR - default iis user)

Resources