IIS 7.5 - Setting up a Virtual Directory for a file share on another domain - asp.net

I have a Windows 2008 R2 server running IIS 7.5. I'd like to set up a virtual directory for my website to allow the download of video files from a file share on a server in another domain. I have a domain username and password that allows me to access this file share. However, when I try to setup the virtual directory in IIS, I get the following error message:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Module: IIS Web Core
Notification: BeginRequest
Handler: Not yet determined
Error Code: 0x8007052e
Config Error: Cannot read configuration file
Config File: \\?\UNC\z27ar1cfvs004.abc.se\video$\web.config
Requested URL: http://localhost:8080/Video
Physical Path: \\z27ar1cfvs004.abc.se\video$
Logon Method: Not yet determined
Logon User: Not yet determined
Weirdly, I can hit Explore on my virtual directory and IIS will launch Explorer showing me the files.
For my site's authentication settings I have Basic and Windows authentication settings enabled.
Here are the things I've tried unsuccessfully:
Changing the Connect As... user for the site to use the domain user credentials
Changing the Connect As... user for the virtual directory to use the domain user credentials
Changing the Application Pool identity for the website to use the domain user account credentials
Creating a local user account on the IIS server with the same username/password as on the domain server, and trying all 3 steps above again but only specifying the username rather than domain\username
Changing the Managed Pipeline Mode: neither Integrated nor Classic makes any difference
I've Googled until my eyes have gone blurry and spent hours trying many recommended suggestions but all to no avail.
How can I solve this problem?

I have found a couple ways around this, depending on what your problem is:
Actually make a web.config file in the shared directory.
Make a <location path="video" inheritInChildApplications="false" /> element in your main web.config to specify that the virtual directory is not allowed to have web.config settings override its parent.
Set up a real directory in your website that does have a web.config in it, and use the URL Rewrite tool to make a set of rewrites to the actual content.
If you have written a custom HTTP Module that is enabled for the site, turn it off for that directory. For instance, if the module does not have to run on static files, add precondition="managedHandler" to its settings in web.config or applicationHost.config.

Related

Unable To Browse or Run Uploaded Project Using IIS Server

I am trying to publish an ASP.NET MVC web application locally using IIS server. The files of the application are uploaded but whenever I run the application in the browser (localhost/WebApp), get the following exception:
HTTP Error 500.19 - Internal Server Error
The Request page cannot be accessed becasue the related configuration data for
the page is invalid.
Module: IIS Web Core
Notification: BeginRequest
Handler: Not yet determined
Error Code: 0x80070005
Config Error: Cannot read configuration file due to insufficient permissions
Config File: \foo\web.config
Request URL: http://localhost/WEBAPP
Logon Method: Not yet determined
Logon User: Not yet determined
Config Source
-1:
0:
I've tried to google and tried to follow this link but seems like need some advice to resolve it: (Clearly unable to understand)
Troubleshoot IIS Issue
Do I need to configure anything else in the Web.config file or in the IIS server?
It seems like you don't have Windows Permission to read the Web.config file and I believe, you don't have to change anything in the Web.config file.
In IIS server, add a user IIS_IUSRS using the security tab in the edit permissions sections. It'll allow all the user to access that file. If you ask about the IIS_IUSRS, it means when a web project is run on the IIS server, it associates the application pool with a user like local system, network services. So make sure about it.

HTTP Error 500.19 - Internal Server Error 0x80070003 Cannot read configuration file

I'm getting the above error when I publish my application and move it from development to production server. Below are the error details.
Detailed Error Information
Module IIS Web Core
Notification BeginRequest
Handler Not yet determined
Error Code 0x80070003
Config Error Cannot read configuration file
Config File \?\C:\inetpub\wwwroot\WorkmenCompTest\web.config
Requested URL http://localhost:80/wictest
Physical Path C:\inetpub\wwwroot\WorkmenCompTest
Logon Method Not yet determined
Logon User Not yet determined
This website used to work previously but recently the published version stopped working due to this error. As far as I can tell, the only change was installing iTextSharp and iTextSharp xmlworker through nuget.
I have tried, without success:
giving modify permission on the site folder to Everyone
checking the web.config file, and using an older version of the web.config file (from when the site worked).
uninstalling iTextSharp and iTextSharp XMLWorker
The project still runs without issue from Visual Studio.
This is solved. The error was caused by the folder name not matching the path for the virtual directory. Oh wow I feel dumb.
Check the applicationhost.config file under - .vs\lpsWeb-UI\config folder of your application root.
Under sites section of the config file check what the physical path points to.
If you modify those you should be able to fix the issue.
This is because of different physical path in the IIS.To change the physical path of application content
You can perform this procedure by using the user interface (UI), by running Appcmd.exe commands in a command-line window, by editing configuration files directly, or by writing WMI scripts.
User Interface
To use the UI
Open IIS Manager. For information about opening IIS Manager, see Open IIS Manager (IIS 7).
In the Connections pane, expand the Sites node and click to select the site in which your application runs.
In the Actions pane, click View Applications.
On the Applications feature page, select an application from the list and then click Basic Settings in the Actions pane.
In the Physical path box, change the path of the application content.
Click OK.
DefaultAppPool application pool runs under the Network Service account. This account is local to the computer and this account does not exist on another computer. Make sure that you configure the DefaultAppPool application pool to use an account that is a domain user. Then, you can use the same account on the WorkmenComp file server. Alternatively, you can create a workgroup account on the WorkmenComp file server.
I am getting this HTTP Error 500.19 error when I am giving physical path as Z:\App_Live in IIS
Instead of using z:\ ,
I used network path \\server\share\live_folder in the IIS physical path – something like this \\server\share\wwwroot\inetpub\wwwroot
Also you may need to specify username/password in "connect as".

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)

Error 500.19 - IIS 7.5 Site based on UNC - File Permissions Problem

I'm trying to get a website in my IIS 7.5 (Win 7 Pro machine) to run via a UNC path to the code for one of the default website and an underlying App. This is the first time I've ever tried to set up a site/app in IIS 7.5 based off a UNC path: a folder on another server in the same domain.
I've tried various things to try to get this resolved. The app pool is running under ApplicationPoolIdentity on my Win 7 Pro PC where I have this site set up.
The runtime error I get when trying to run the app in the browser via http://localhost/TheAppName is:
Module: IIS Web Core
Notification: Unknown
Handler: Not Yet Determined
Error Code: 0x800700005
Config Error: Cannot read configuration file due to insufficient permissions
Config File: \\?\UNC\theServerName\www\TheAppName
Requested URL: http://localhost:80/TheAppName
Physical Path: (nothing showing up here)
Logon Method: Not yet determined
Logon User: Not yet determined
I put in fake names for the server and app name above for privacy for this post.
So it's having trouble reading the web.config found in that UNC path for this site.
I tried to add a local user on the target server and then then gave that user permissions to the web.config and then used that user RemoteServerName\LocalUserICreated as the app pool's Identity on my machine but it had no effect.
No clue what to do here and how to go about it.
I assume the UNC path is to a different server?
If so are both servers in the same domain? If so then IIS needs to run the website under a user account that has permissions to read the files.
If not you need to create identical user accounts (same username, same password) on the web server and the file storage server and then change IIS to run the website under this user account.
Hope this helps/works.
When you create a web application or virtual directory from a UNC path, you need to provide the credentials to IIS for the connection.
In the Add Application dialog, below the Physical path section is the "Connect as..." button - you can then choose either "Application user (pass-through authentication)" or "Specific user".
Which ever you choose, they have to be credentials that will be recognised by the remote server - "Pass-through" will try and use the current desktop (or browser) credentials to authenticate the user which (if you're connecting via a VPN as per your comments) almost certainly won't be valid. In this case you should use "Specific user" and provide (ideally) a domain user with suitable permissions to run the site.
When we've needed to do this in the past, we'd create an account on the domain that the local AppPools would run under, and then this could be used in these situations as well.
If you've already created the application, the dialog can be reached using the "Basic Settings..." action link.
I took me a few hours to finally solve the same issue for myself. Turned out I used the wrong slashes in my physical path. It should be \ these, not // these.
Zhaph and Alan both identify the work-around suggested by Microsoft. Here's the rest of the information from Microsoft's page on your problem:
Cause
IIS 6.0 uses the hosting worker-process identity to connect to a remote directory. Then, IIS 6.0 authenticates the user against the remote directory. However, IIS 7.0 introduces delegation scenarios. In IIS 7.0, you can delegate Web-site settings and application-level settings to a Web.config file.
For pass-through authentication, the Web.config file is stored in a UNC directory. Therefore, the default-process identity in IIS 7.0 must examine the Web.config file first to determine whether any security-related settings must be applied before the authentication process starts. The default-process identity in IIS 7.0 does not have sufficient permissions to open the Web.config file. Therefore, the Web request is rejected.
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.
Resolution
To resolve this behavior and to make sure that pass-through authentication works correctly, follow these steps:
Make sure that all the user accounts that access the UNC directory have at least the Read permission for the UNC directory.
Note This behavior is the same as the behavior in IIS 6.0.
Make sure that the IIS worker-process identity is running under a domain account or under a workgroup account that also exists on the UNC file server. If it is necessary, create an account on the UNC file server that has the same user name and the same password as the IIS worker-process identity.
Notes
This behavior differs from the behavior in IIS 6.0.
By default, the DefaultAppPool application pool runs under the Network Service account. This account is local to the computer, and this account does not exist on another computer. Therefore, make sure that you configure the DefaultAppPool application pool to use an account that is a domain user. Then, you can use the same account on the UNC file server. Alternatively, you can create a workgroup account on the UNC file server and on the computer that is running IIS 7.0.
If there is a Web.config file in the UNC directory, edit the discretionary access control list (DACL) for the Web.config file so that the DACL contains the account that you verified in step 2. Alternatively, edit the DACL for the Web.config file so that the DACL contains the account that you created in step 2.
If there is no Web.config file in the UNC directory, edit the DACL for the UNC directory so that the DACL contains the account that you verified in step 2. Alternatively, edit the DACL for the UNC directory so that the DACL contains the account that you created in step 2.
Note This behavior differs from the behavior in IIS 6.0.

Do I need a web config file to run an asp.net hello world on IIS 7?

I have uploaded a simple hello world on my IIS server 7 (shared hosting). It doesn't work. Is it necessary to add a web config and what's the minimum in that case ?
Thanks.
Error says:
Server Application Unavailable
The web application you are attempting
to access on this web server is
currently unavailable. Please hit the
"Refresh" button in your web browser
to retry your request.
Here's the script, very basic :)
<%# Page Language="VB" %>
<html>
<head>
<title>ASP.NET Hello World</title>
</head>
<body bgcolor="#FFFFFF">
<p><%= "Hello World!" %></p>
</body>
</html>
A individual, site-specific web.config is not required to be present in order to get a basic "Hello World" site up and running in IIS7, however, it's rather unusual not to have one.
IIS7, unlike previous versions, effectively has the ASP.NET worker process component "built-in". This allows web.config files to specify configuration of not only your ASP.NET site itself, but also how the IIS server hosting your site should be configured (i.e. you can specify (for example) the default document type in an ASP.NET web.config file).
If you don't specify an individual web.config for your ASP.NET site, the IIS7 server will use the "default" web.config, which is usually located in your "windows" folder within the system-wide configuration of the .NET framework itself.
This article:
Working With Configuration Files in IIS 7
from the MSDN library states:
Configuration Files
Configuration exists in a physical
directory in either server-level
configuration files or in Web.config
files. Every configuration file maps
to a specific site, application, or
virtual directory.
Server-level configuration is stored
in the following configuration files:
Machine.config. This file is located in
%windir%\Microsoft.NET\Framework\framework_version\CONFIG.
Root Web.config for the .NET Framework. This file is located in
%windir%\Microsoft.NET\Framework\framework_version\CONFIG.
ApplicationHost.config. This file is located in
%windir%\system32\inetsrv\config.
Site, application, and virtual and
physical directory configuration can
be stored in one of the following
locations:
A server-level configuration file. When configuration for a site,
application, directory, or URL is
stored in a server-level configuration
file, you must use a location tag to
specify the site, application,
directory, or URL to which the
configuration applies.
A parent-level Web.config file. When configuration for an application,
directory, or URL is stored in a
parent-level configuration file, you
must use a location tag to specify the
child at which the configuration
applies.
The Web.config file for the site, the application, or the directory.
When you configure settings for an
application, directory, or URL, the
configuration is stored in the same
directory as the site, application, or
directory. You do not need to use
location tags.
Storing configuration settings in a
parent configuration file is helpful
when:
You want to store configuration settings in a configuration file that
is accessible by only certain users or
groups. For example, the
ApplicationHost.config file is
available only to the Administrator
account and to the members of the
Administrators group on a specific
computer, as well as to domain
administrators when a computer is part
of a domain.
You want to configure a feature at the URL-level (also known as
file-level).
Also, see the following article for further information:
The new Configuration System in IIS 7
EDIT:
Regarding the specific error message that you're getting, I've seen this before on an IIS7 server, and the problem turned out to be the Application Pool that the site was set to use wasn't "running". Going into the IIS7 admin gui and starting the Application Pool cured the problem.
I have also seen this error caused wen the relevant permissions have not been set on the folder containing your website code.
See here, here, and here for further information.
Of course, since you're testing a shared hosting environment, you probably don't have access to the web server itself, and it's difficult to know exactly what you do have access to, administration-wise, through your hosting provider, but they probably have some kind of interface to set permissions on folders/files, so I'd look there first.
Failing that, you may have to include a web.config file in your "test" site as that will allow you to set configurations within IIS7 that you may otherwise have no access to.
Failing that, you may need to speak to your web host's support team.
It should be enough to inherit from machine.config. What's the exception?
I am not sure about the shared Hosting environment. But If you try to create a web application ( try ASP.Net Empty web application template) and just use Response.write("Hello World !") . it will work without any web.config.
I tried my self and it work successfully.
Only problem is that It may ask you if you wanted to debug your application then it requires to add "compilation = true" attribute in web.config.

Resources