I recently moved my "My Documents" folder from the C: to the D: drive. This seems to have broken my ability to debug web app in Visual Studio. I'm assuming that visual studio creates entries like the following in applicationhost.config, and I am wondering where the first physicalPath for the root virtualDirectory comes from, as I am fairly certain that is the problem (I've pretty much confirmed that VS creates an entry like the following when a solution is opened):
<site name="My.Application-Site" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\myname\Documents\My Web Sites\My.Application-Site" />
</application>
<application path="/My" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="D:\repos\MyCheckout\My\My.Application" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:49924:localhost" />
</bindings>
</site>
When I try to run the app in debugger, the browser pops up with an error, the relevant bits of which are below. Notice the path to web.config still uses C:, even though it seems to know the right place for tracelogfiles:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Config Error Cannot read configuration file
Config File \\?\C:\Users\myname\Documents\My Web Sites\My.Application-Site(2)\web.config
Requested URL http://localhost:50616/My/
Request Tracing Directory D:\users\myname\My Documents\IISExpress\TraceLogFiles\
So the question is where in Visual Studio (or IIS) is the path for the web.config file determined, and how do I change it. And/or is there some other reason or insight anyone can provide as to why I am getting this 500.19 error?
Another recent change (other than moving My Documents) is I uninstalled a trial of VS Ultimate 2013 and installed VS Pro 2013 -- could that have somehow caused this? Both of changes have been made between the time I was last able to debug the app normally and getting this error.
For someone looking for an answer to "where in Visual Studio (or IIS) is the path for the web.config file determined, and how do I change it" or "I moved my application from its origin folder"
Right-click in Project Properties > Web Tab and Create Virtual Directory buttom.
It all happened when I was developing (and debuging, of course) my application on two different machines, with different paths (and Drives) to the source code managed by git.
Hope it helps
Related
I am running IIS under Windows Server 2016 and I'm trying to run an ASP.Net core 3.1 application but I can't get past this error:
500.19 error
(The language in the picture is Hungarian, but it contains no useful information whatsoever, just an example)
Here is my web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\Minibizz.Routing.Web.exe" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
</system.webServer>
</location>
</configuration>
What am I missing?
P.S.: The web.config was created by Visual Studio 2019.
The reason behind the issue:
That error message goes on to say what exactly is bad about your configuration file, hence you should refer the “Config Error” and “Config Source” sections. This problem occurs because of the ApplicationHost.config file or the Web.config file contains a malformed or unsupported XML element.
if you are using url rewrite rule then install url rewrite Extention of iis. Enable ANCM logging, ie. set stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout\" (I think the path needs to end by a backslash), then run the web app and see if something gets logged into the stdout folder. Verify that the log directory exists at the path referenced by the web config. If it does not, create it. The path shown in your config would place the "logs" directory in the root folder of the deployed site. Verify that the application pool has to write access to the logs directory.
Make sure you installed the .net bundle.check that you installed below iis feature:
You may also need to verify that the path to the dotnet executable exists in the deployment machine's environment variables. To check this, first find the path where dotnet.exe is installed. It is generally located in either C:\Program Files\dotnet or C:\Program Files (x86)\dotnet. Once you know the path, ensure that the path exists in your Environment Variables.
The web.config content seems to be correct. If you use a clean web.config copy, does the problem persist? If the issue can be solved by replacing web.config with clean configuration content, then the problem is exactly with this web.config. In this case, I suggest you remove parts of the web.config content to narrow down the issue. If the pages show correctly after you remove one section, then the problem is with that section. You need double-check what's wrong with the section and update the correct configuration.
If the problem remains even with clean web.config content, I suggest you access other pages in different folders in your site to see if the problem still exists.
you could refer this below link for how to publish asp.net core site in iis:
https://learn.microsoft.com/en-us/aspnet/core/tutorials/publish-to-iis?view=aspnetcore-3.1&tabs=visual-studio
In IIS under the site I can create a virtual directory which has a different phisical path.
Can I somehow do the same in ASP.NET MVC project? Something like adding a directory which links to a different directory.
The problem is I have some folder outside the site which contains images. I added that folder in IIS under site as Dropbox, which points to completely different location:
Now I also use such paths in the app with Server.MapPath:
"~/Dropbox/Dev/Product/Images"
This all works when I publish in IIS. But how can I do the same locally debugging? Is there a way to add virtual directory to my project in Visual Studio?
I am assuming that your are running your website using IIS Express. You can find your website IIS Express configuration file by right clicking the IIS Express tray icon and then show all applications. Select your website and then click on the config path as shown in screenshot
In config file, find your website site element and then you can add new virtualDirectory element like this:
<site name="Website1" id="2">
<application path="/" applicationPool="website1">
<virtualDirectory path="/" physicalPath="D:\Projects/Website1" />
<virtualDirectory path="/Images" physicalPath="C:/Images" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:54558:localhost" />
/bindings>
</site>
Here you can see Images virtual directory is added.
I need to have WebAPI project working under different base path than usual. I created simple project under Visual Studio that uses WebAPI and ASP.NET 5.
Under base path set to http://localhost:38170/ my project works fine and I'm able to get values from test controller (http://localhost:38170/api/values).
At this stage my IIS Express configuration is:
<site name="WebApi" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\WebApi\src\WebApi\wwwroot" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:38170:localhost" />
</bindings>
</site>
I tried changing App URL under project properties to reflect my need:
http://localhost:38170/xxx
Now running project and hitting http://localhost:38170/xxx/api/values results in 404. Trying http://localhost:38170/api/values returns values from controller just as if nothing changed. I noticed that changes in Visual Studio are not reflected in IIS Express configuration (I don't know if they should be...) in any way.
I tried changing path on IISExpress manually like in this thread: Creating virtual directories in IIS express.
<site name="WebApi" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/xxx" physicalPath="C:\WebApi\src\WebApi\wwwroot" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:38170:localhost" />
</bindings>
</site>
The results are:
http://localhost:38170/api/values - 500.19 Error (config error) and that is fairly ok - I don't plan this to work
http://localhost:38170/xxx/api/values - 502.3 - Bad Gateway on hitting httpPlatformHandler
I suppose that error is somewhere in httpPlatformHandler configuration but I'm not sure how to do it in conjuction with IIS Express. My web.config is:
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" startupTimeLimit="3600"/>
</system.webServer>
</configuration>
I tried random changes like changes in path attribute to xxx/* but nothing works.
EDIT:
To clarify the question.
How to setup WebAPI on ASP.NET 5 (ASP.NET Core) on IISExpress using httpPlatformHandler and Kestrel to set base path other than root.
You corrupt the file as your modification does my honor the IIS Express configuration rules.
I will suggest you use a smart tool such as Jexus Manager to manipulate it, and then you can sync the Visual Studio project with the correct URL.
For example, the 404 is expected, as your application tag has path set to /, so there is no application nor virtual directory to serve xxx.
The 500.19 later is also expected, as while adding a valid virtual directory named xxx, you deleted the root virtual directory. That's totally wrong as a root virtual directory must present.
I have a really frustrating problem. I have a website in ASP.NET. I use IIS Express for development. I recently moved my project files and folders from a usb drive to my dropbox folder to avoid carrying the drive around.
After moving my project to the dropbox folder, I got this error that IIS cannot read my config file. I noticed the path was pointing to my usb drive. So I copied my web.config to the path displayed in the error message and it worked again, if I delete it again, the error comes again.
So I think that somewhere in my project there is a config setting that points to my usb drive, although it should point to my local dropbox folder.
I have attached a screenshot of the error:
Translation:
Module IIS Web Core
Message Unknown
Handler still undetermined
Error code 0x80070003
Config error The config file cannot be read
Config file .........
Requested URL ...........
Physical path
Authentication method still unknown
Authenticated user still unknown
Debug path ..................
I had this problem when trying to launch a service from a project created on another machine that was saved in DropBox.
In the project folder there is a file in PROJECTFOLDERNAME/.vs/config/applicationhost.config
In that file is a list of sites in XML like so:
<sites>
<site name="WebSite2" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\WRONGPATH\Dropbox\Website2\src\Website2" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:64655:localhost" />
</bindings>
</site>
<site name="WebSite4" id="3">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\Nick\Dropbox\Website3\src\Website3" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:64655:localhost" />
</bindings>
</site>
<siteDefaults>
<logFile logFormat="W3C" directory="%IIS_USER_HOME%\Logs" />
<traceFailedRequestsLogging directory="%IIS_USER_HOME%\TraceLogFiles" enabled="true" maxLogFileSizeKB="1024" />
</siteDefaults>
<applicationDefaults applicationPool="Clr4IntegratedAppPool" />
<virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>
Change the virtualDirectory physicalPath to the correct path. The problem I still face is I work on this project from two different locations, I don't really want to change this back and forth all the time.
Uhh, I have looked for the answer for more than 2 hours. I tried cleaning up every bin, .vs folders. But those did not help me.
Eventually, I fixed the issue by re-showing (re-binding) the path to the project in IIS Manager
I had this issue when I moved my "My Documents" folder to another location. IIS Express was still pointing to old path. The only way I could fix this is by doing clean installation of IIS Express.
Uninstall IIS Express
Remove the 'IIS Express' folder that contains configuration file.
Install IIS Express
Is there a way to rebuild the applicationHost.config file in IIS 7 with a Windows command? Or if you can help me fix the issue by modifying this file, that's fine too. When comparing this file to other servers, I'm noticing very important sections that are missing or different after deleting a site and a few application pools.
I am by no means an expert in IIS 7, but I've been using it for 7 years now. I am confident have performed all of the proper steps for a new site configuration and it still gives me this error, "401.1 "You are not authorized to view this page. You do not have permission to view this directory or page using the credentials that you supplied."
C:\Windows\System32\inetsrv\config\applicationHost.config
This happened on a machine where IIS APPPOOL{app pool user} doesn't exist, so we've never used this user, like I normally do when configuring permissions. We did however add proper permissions to IIS_IUSRS (with IUSR in this group) last week, and the site worked fine. We're using Windows Authentication, and all other authentication methods are turned off. No virtual directories. We are using .NET 4.0, Classic, and 32 bit app (under advanced settings).
We had to manually update the host name by doing the following command in "C:\Windows\System32\inetsrv" on the binding because IIS would grey out the host name when the VeriSign SSL certificate was added to the binding.
appcmd set site /site.name:"himc" /+bindings.[protocol='https',bindingInformation='*:443:subdomain.domain.com']
Missing sections on "bad" web server:
1 - exists on "good" box, missing on "bad" box
<customMetadata>
<key path="LM/W3SVC/INFO">
<property id="4012" dataType="String" userType="1" attributes="Inherit" value="NCSA Common Log File Format,Microsoft IIS Log File Format,W3C Extended Log File Format,ODBC Logging" />
<property id="2120" dataType="MultiSZ" userType="1" attributes="None" value="400,0,,,0
" />
</key>
</customMetadata>
2 - exists on "good" box, missing on "bad" box
<asp>
<cache diskTemplateCacheDirectory="%SystemDrive%\inetpub\temp\ASP Compiled Templates" />
</asp>
3 - this section exists on the "good" box, but only 2.0 (first 2 lines) exist on the "bad" box.
<isapiFilters>
<filter name="ASP.Net_2.0.50727.0" path="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_filter.dll" enableCache="true" preCondition="bitness32,runtimeVersionv2.0" />
<filter name="ASP.Net_2.0.50727-64" path="%windir%\Microsoft.NET\Framework64\v2.0.50727\aspnet_filter.dll" enableCache="true" preCondition="bitness64,runtimeVersionv2.0" />
<filter name="ASP.Net_2.0_for_V1.1" path="%windir%\Microsoft.NET\Framework\v2.0.50727\aspnet_filter.dll" enableCache="true" preCondition="runtimeVersionv1.1" />
<filter name="ASP.Net_4.0_64bit" path="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_filter.dll" enableCache="true" preCondition="runtimeVersionv4.0,bitness64" />
<filter name="ASP.Net_4.0_32bit" path="C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_filter.dll" enableCache="true" preCondition="runtimeVersionv4.0,bitness32" />
</isapiFilters>
4 - this section exists on "bad" box, but is missing on the "good" box
<applicationDependencies>
<application name="Active Server Pages" groupId="ASP" />
</applicationDependencies>
5 - ssiExecDisable property is missing on "good" box
<serverSideInclude ssiExecDisable="false" />
6 - section missing on "bad" box
<authentication>
<anonymousAuthentication enabled="false" />
<windowsAuthentication enabled="true" />
</authentication>
Apparently, Microsoft keeps a history of these files in:
C:\inetpub\history\
Do a backup of all config files first!
So apparently, IIS keeps a history of the config files in C:\inetpub\history. So what you need to do is remember the last known date IIS worked fine and then copy the contents of the config file from c:\inetpub\history and replace config files in c:\windows\system32\inetsrv\config.
Good luck!
If you just want to modify currently active applicationHost.config take a look at this article:
Editing Applicationhost.config on 64 bit Win2008
As the article says, for some reason applicationHost.config is visible only using Explorer (which explains why I wasn't seeing file from my custom file manager) and you can edit it without problems using Notepad (again, any other editor and you'll run into problems).
The inetpub history folder saved my butt. I simply restored the two files in the root folder and wallah problem solved.
To install a backup of an older configuration, you can use the command:
c:\windows\system32\inetsrv\appcmd restore backup CFXHISTORY_xxxxxxxx
where CFXHISTORY_xxxxxxxx is a sub folder of C:\inetpub\history\.
Not sure what the command does besides copying files from that folder to the current configuration, but you should probably use it in case it does do something special.
Or you can just copy the file from the backup as explained in https://stackoverflow.com/a/14859645/2279059