Related
I want to upload my own asp.net website on IIS with IIS Manager. But when I do this, I get the following error
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 Unknown
Handler Not yet determined
Error Code 0x80070005
Config Error Cannot read configuration file due to insufficient permissions
Config File \\?\C:\Users\Yasso\Documents\Visual Studio 2008\WebSites\WebSite5\web.config
I searched many times for a solution for this error, but none of the solutions solved the error.
I have a problem with my IUSR account. I can't see this account in the "group or user names" in the properties of the web.config.
What is the problem?
This can also happen if the site is configured to use the IIS URL Rewrite module but it is not installed.
Finally, I got the solution for my problem. The ASP.net account did not appear in the IIS manager, because I didn’t check its checkbox in IIS. To do this in Windows 7 follow the steps:
Open control panel
Click on “program” link (not uninstall programs)
Click “turn windows features on/off” link
Locate “Internet Information services IIS” in the pop up window and expand its node
Expand the “World Wide Web Service” node
Expand “Application Development Features” node
Check the check box of “ASP.NET”
Then click ok button
Now, you will see the ASP.net account on the IIS manager and by default you will see the IIS account. Now, you should move your ASP.net website from “my document” to another place where the IIS have permission to access it (i.e. to another partition on your computer). Now, browse your website from the IIS manager and it should work.
Thanks a lot for Jeff Turner for the solution.
The message is saying that your configuration file is corrupt in some way. However it also says that it can't actually access the config file. So I'd ignore the original message about corruption/lack of validity as this is most likely just the effect of not being able to read the file due to a lack of authorization.
The reason it cannot read the config file is because the process running your web app does not have permission to access the file/directory. So you need to give the process running your web app those permissions.
The access rights should be fairly straightforward, i.e. at least Read, and, depending on your app, maybe Write.
Above, you mention IUSR etc. not being in the properties for web.config. If by that you mean that IUSR is not listed in the security tab of the file then it's a good thing. One doesn't want to give IUSR any kind of permission to web.config. The role IUSR is an anonymous internet user.
The file web.config should only be accessible through your application.
The problem is you haven't said which OS and IIS version you are using so it's difficult to advise which steps to take.
I.e. in IIS 7.5, the error message you're quoting is likely to occur due to your ApplicationPoolIdentity not being assigned the permissions. Your web application belongs to an application pool and so you need to give the permissions to the OS account that your web application's application pool runs under. Often this is something like NetworkService but you may have customized it to run under a purpose made account. Without more info it's difficult to help you.
I was having the same problem, here is the solution that worked for me.
IIS Manager
Right clicked on that Website
Edit Permissions
Added user 'IIS_IUSRS' from Security tab
Gave full permissions to User 'IIS_IUSRS'
Set the Application Pool's Identity to 'ApplicationPoolIdentity'
For Visual Studio (VS) developers:
As hinted at by Harvey Darvey, Savage, and Snives, your Application Host Configuration may be pointing to the wrong application physical path. Search for virtualDirectory within /.vs/config/applicationhost.config to change the physicalPath if it is incorrect.
Make sure the physicalPath is correct:
Just to chip in, I received the same kind of error and my problem was quite simple: I was missing the .NET Core Hosting Bundle. Once I installed the tool and restarted the server, it was fine.
You can find the manual to host asp.net core on windows here: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/?view=aspnetcore-2.2
To resolve this, make sure you installed the hosting bundle.
https://dotnet.microsoft.com/download/dotnet-core/3.1
Facepalm alert:
You will also get this error if the path to the config file is wrong. Double-check it to make sure the physical path is entered correctly in IIS.
You need to assign permissions for IIS_IUSRS on the local machine (but you don't have to assign for IUSR, in fact it will work even if you explicitly deny permissions).
To assign permissions, just right click on the folder and on the security tab make sure to grant the correct permissions, and if the user is not listed then click "ADD", and enter IIS_IUSRS (and make sure that under "domain" the local computer is selected, or enter in the name field YourLocalComputerName\IIS_IUSRS), and then you are good to go.
If you want you can instead of assigning permissions to the IIS_IUSRS group, you can instead assign to the app pool which should in general be "IIS APPPOOL\ app pool name".
The same thing happened with me , Try checking this by double clicking on the Connection strings on the right pane of IIS 7 when you select a website.
It will give you an error (that there is some problem with web config file), because you have used URL rewrite rules and the respective component is not installed.
Install “Microsoft URL Rewrite Module 2.0 for IIS 7” and this should fix your problem
Install ASP.NET Core module
Download the installer using the following link:
https://www.microsoft.com/net/permalink/dotnetcore-current-windows-runtime-bundle-installer
Nothing here worked for me, I found this command in another SO answer though and it solved my problem. Just start command prompt as an administrator and run this command:
run->cmd
run "c:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -i"
Credit: User Vicxx
Ehm. I had moved my site/files to a different folder. Without changing the path in the IIS website.
You may all laugh now.
I do these steps to solve this problem in
Windows Server 2012, IIS 8.5. Should work for other versions too.
Go to server manager, click add roles and features
In the roles section choose: Web Server
Under Security sub-section choose everything (I excluded digest, IP restrictions and URL authorization as we don't use them)
Under Application Development choose .NET Extensibility 4.5, ASP.NET 4.5 and both ISAPI entries
In the features section choose: NET 3.5, .NET 4.5, ASP.NET 4.5
In the web server section choose: Web Server (all), Management Tools (IIS Management Console and Management Service), Windows
Make sure you have the application pool set to the correct version of the framework. You'll also need to make sure your aspnet, IIS_IUSRS, or IUSR users have read access to the application's directory.
Try installing the 'Application Development' sub component of IIS as mentioned in this SO
Click "Start button" in the search box, enter "Turn windows features
on or off"
in the features window, Click: "Internet Information
Services"
Click: "World Wide Web Services"
Click: "Application
Development Features"
Check (enable) the features. I checked all but
CGI.
One other possibility that fixed this problem for me:
IIS -> Edit Permissions -> Security Tab -> Give "Users" appropriate permissions (or IIS_IUSRS, depending on your setup)
This also happened to me when I had a default document of the same name (like index.aspx) specified in both my web.config file AND my IIS website. I ended up removing the entry from the IIS website and kept the web.config entry like below:
<system.webServer>
<defaultDocument>
<files>
<add value="index.aspx" />
</files>
</defaultDocument>...
Sometimes this message has can be missing components in your IIS environment e.g. a particular framework, or an IIS feature like dynamic compression, rather than permissions to web.config.
If this is the case, a solution can be to install and use the Microsoft Platform Installer and install those missing components - you might have to take a stab at what exactly is missing because the error log and message don't tell you.
Actually, any missing module can lead to this problem. In my case, it was CORS Module. So read the web.config and seek for any addon module that you specified in it and check that it is installed, or install it otherwise. Unfortunately, the error message does not help finding the problem at all.
Pretty straight forward, IIS doesn't have access to your web.config. I'd start by taking the site out of your documents folder. Verify it has r/w permissions then as well.
You need to set permission for your Website folder or copy they to wwwroot folder :)
- If set permission, have 2 way:
+ Right click to Your Website folder
+ Or right click to Your Website in IIS
=> select Edit permission and Add a permission (IUSR - default iis user)
Good luck ;-)
You can get this error if you have a synax error or issue in your web.config file.
For me, it was a stray ampersand in a URL that I was using in the AppSettings.
In my case, it caused by application physical path point to a non-existent folder in IIS.
got this problem with mapped drives, IIS doesn't work with mapped drives. Just use the unmapped drive.
I had the issue as I copied my web.config file down from prod, changed everything not prod related except the Rewrite rules which were rewriting to httpS.
Removed those rules and ran fine.
I too had the similar issue and i fixed it by commenting some sections in web.config file.
The project was earlier built and deployed in .Net 2.0. After migrating to .Net 3.5, it started throwing the exception.
Resolutions:
If your configuration file contains "<sectionGroup name="system.web.extensions>", comment it and run as this section is already available under Machine.config.
On the IIS 7.5 error page you get click on 'View more Information' at the bottom of the page and in this case it will take you to the following Microsoft link:
http://support.microsoft.com/kb/942055
The 0x80070005 Error Code seems to be permissions related and following the steps in Resolution 2, Method 2 assigning the correct accounts with permissions on relevant folders should fix it - I spent 3 days looking for a solution until I came across it, worked straight after.
Explore the folder where your website is store and see you will get one extra folder "aspnet_client" delete that folder and it will work for you.
I tried this my problem is solved.
If it works for you please make it as answer so that some body else will also get solution.
None of this worked for me, but I finally have a solution which worked for me:
remove this line in web.config:
<compilation debug="true" targetFramework="4.5"/>
don't remove this line
<compilation debug="true"/>
I have written a program in the last days which automatically changes the proxy server. This runs as a Windows Forms Tray Application on the user level.
Now came a request which caused me some problems. A cmd command "ipconfig /registerdns" should be executed but this requires higher permissions.
I'm now looking for a way to easily execute this command in normal user context. Is there a way to run this one command as a system? Or any other possibility?
Or is there another function to re-register the dns without admin priviledge?
I hope there is a easy way.
Thank you very much!
As i know admin processes can only be created by another admin processes but still you can try adding this parameter to your process's start info
StartInfo.Verb = "runas";
if it doesnt work you set your application to run always as admin by adding app.manifest to your project and editing line 19 as below.
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
Create a script (.cmd or .bat) containing required command (here: "ipconfig /registerdns"), then flag it as "Run as administrator". Finally, run this script from your app instead of original command.
This should help in flagging as "Run as administrator": How to code a BAT file to always run as admin mode?
Okay so I found no solution for my former problem, because it is not possible to launch a elevated command from a user Application. But I found a powershell command: Register-DnsClient. This command does the same and does not need elevated priviledges. Only downside is it works only on Windows 8.1 and newer. So Windows 7 is not supported.
I created a service in C# which generated an executable "GodzillaService.exe". The service itself is just a basic template generated EXACTLY according to this link, other than the name: https://www.c-sharpcorner.com/article/create-windows-services-in-c-sharp/
The issue comes when I try to run InstallUtil. Per the article above, I execute
cd C:\Windows\Microsoft.NET\Framework\v4.0.30319
on an elevated command prompt, run as administrator. I then type in
InstallUtil.exe C:\Path\To\My\EXE\Godzilla.exe
and I get hit with this error:
An exception occurred during the Install phase.
System.InvalidOperationException: Cannot open Service Control Manager
on computer '.'. This operation might require other privileges. The
inner exception System.ComponentModel.Win32Exception was thrown with
the following error message: Access is denied.
Looking at the error message, experience tells me that I need to grant access to something or someone, but what? I'm already running the program as an administrator. I've tried these things so far:
Run command prompt as administrator.
Run Developer Command Prompt for VS 2017 as administrator.
Log out of my user account, log in to my admin account, and try running it.
Move the GodzillaService.exe file into Program Files directory in case applocker is messing with it.
Run VS 2017 as admin, rebuild the exe file, then try it.
Try using the full path of both the exe file and InstallUtil.
Made sure my admin account was in the local admin group.
Tried looking at Event Viewer for more information (did not find any logs related to this issue, maybe I'm looking in the wrong place?)
Tried changing the account in the service program from LocalSystem to User, LocalService, and to NetworkService
I'm fresh out of ideas... Does anyone have any suggestions for what I can do to further troubleshoot this problem? I appreciate any advice given!
It took me a while, but I was able to finally figure this out! The problem was that even though I said I was running it as an administrator, I was running it as a user with administrator privileges. Completely different.
In my environment (which is a domain environment), for some reason we have the "Run as Administrator" option blocked for running programs. Thus, to run things as an administrator, we actually have to run it as a different user, and then select our admin account. This works for 99% of things, but not for this case.
The solution was that I had to log completely out of my regular user account and log in with my administrative account. Then, I had to right click on command prompt and Run As Administrator. Upon doing this, I no longer received the error!
What I'm doing:
Opening Visual Studio Community 2015
File -> New -> Project
Under Visual C#: Web -> ASP.NET Web Application
Web Application
And press f5 for the popup error "unable to connect to web server 'IIS Express'."
Deleting applicationhost.config, located in Documents\IISExpress\config, doesn't change the error message. (There's also an IISExpress folder in program files and program files (x86).)
Something I noticed, and I don't know if it's a problem:
Referenced file 'lib/jquery-validation/jquery.validate.js' not found.
I got a dump with rawcap but I don't notice much in there. Some of what was there:
"Framework":{"FrameworkName":"DNXCore,Version=v5.0","FriendlyName":"DNX Core 5.0","ShortName":"dnxcore50","RedistListPath":null}
I don't notice a problem, but I have the network data if that can help figure out why I cannot connect to the web server. I get a RST,ACK immediately so I'm guessing the port is closed and whatever this web server is, isn't being setup.
More on this problem: 800700c1 error from /trace:error
I've tried:
deleting applicationhost.config (and changing port number)
running visual studio as administrator
deleting IISExpress folder in Documents (changes error message until the folder is reinstalled)
toggling ssl off and on, copying url to launch box. (note: I'm not using ssl)
clearing all sfc /scannow errors
starting iisexpress with x86 version and 64-bit version
After installing Update 2 for Visual Studio 2015 I started getting the same error. I tried everything above with no luck. However, I found a solution that works for me:
Delete YourSolutionFolder\\.vs\config\applicationhost.config file (note: .vs is a hidden folder)
Open Visual Studio, right-click on web site > Properties > Debug tab > Web Server Settings > App URL - change port number.
If you have IIS configured to use the same port, (stop the application / use different port) and try again.
Exit VS and delete the (project)\.vs\applicationhost.config file. Restart VS. It should start working.
Try using a different port. I just set up a new Core 1.0 RC1 project and got the same error.
Right click web project
Debug tab
Toggle Enable SSL off and on again, it should generate a new random port
Copy the SSL URL and paste into Launch URL box
Run the project
Worked for me (TM).
Answer from: https://stackoverflow.com/a/28650554/134761
I had this issue on .net core 2.1, visual studio version 15.9.6. When i deleted the .vs folder, i reopened visual studio and the problem was still there. The solution that worked for me below:
Delete .vs folder (it is a hidden folder).
Restart Computer.
Other Solutions:
Close Visual Studio, delete bin and obj folders from the project folder. Open Project then rebuild solution.
Try running Visual Studio as Administrator.
Clean Solution then rebuild
Clean Solution. 2) Exit Visual Studio. 3) delete .vs folder 4) Re-open Visual Studio
Restart machine (if you can afford to)
Copied my comment to an answer by request.
For Net Core 2.2 project - After a MASSIVE struggle and trying everything from deleting .vs folder, deleting IIS Express configs, changing port numbers, changing bindings, and to running VS as admin I FINALLY fixed issue by
closing VS,
deleting launchSettings.json
opening VS which re-generated launchSettings.json.
It was not apparent that the file was corrupt or incorrect or even when it changed to cause failure.
I faced this issue in .net core 2.0 when I update my project's port number.
I was able to sort out issue in two steps :
STEP 1 : DELETE .vs folder which is hidden inside main solution folder. (close visual studio before this) then when you start again visual studio, this folder and file (applicationhost.config) inside it will automatically create by visual studio.
STEP 2 : For multiple startup projects, if you are still facing issue then one by one run project as startup, and then run as multiple startup project.
I had the same issue, i was able to solve it by changing the Port number.
Right click on the project and select properties
Go to the Debug section
Under Web Server Settings change App URL port [just increase by one :)]
In my case that was some other application listening on the same port which IIS Express trying to attach to. I have to run netstat -ao to see PID of process which is use same port and shutdown application. In my case application was Viber.
I just changed my profile from "IIS Express" to "MyProjectName" (which I think is using kestrel as the http server instead of IIS) and now it's working fine:
Run VisualStudio with administrator privilegies and run the project. Then close VisualStudio and all errors and run VisualStudio again with the normal user.
This did it for me.
Looks like that IIS has to write something to some config with admin privilegies (port 80 didn't work with normal user but port 6767 worked fine).
Many of these answered don't fully address the issue at hand. The real problem for me was that I had two bindings using the same port in my applicationhost.config file AND I hadn't opened up the port to my second (non localhost) binding. VS will allow you to still run under these circumstances but only if you are in admin mode (hence all of the answers above).
You are essentially creating two IIS express instances of your app on the same port, so changing one of the ports in your applicationhost.config file will allow you to proceed. There are two different applicationhost.config files however. You will want to select the one that has the binding IP and port that you see in your project's properties
.
Go to the folder where you can see your project solution and project folders (show hidden items in File Explorer). Navigate into your hidden .vs folder -> "YourAppName" folder -> config. It should contain the binding info you saw in your project's properties.
Example:
<bindings>
<binding protocol="http" bindingInformation="*:7000:127.0.0.1" />
<binding protocol="http" bindingInformation="*:7000:192.168.0.5" />
</bindings>
Change one of those port numbers to something other than "7000" so that you aren't trying to use the same port.
In my case, I'm using a 192 address which is not a localhost address, so I need to use some netsh commands to open that port and ip up. Here is a Link that shows how to open up ports for IIS Express to allow remote connection. Running as a normal user will not work unless you run those netsh commands listed.
Here are the netsh commands:
netsh http add urlacl url=http://192.168.1.42:58938/ user=everyone
netsh advfirewall firewall add rule name="IISExpressWeb" dir=in protocol=tcp localport=58938 profile=private remoteip=localsubnet action=allow
Copy those commands and run them in cmd with ADMIN privileges and with YOUR ip address and port number.
TO CLARIFY
Really a lot of answers here are the same and say something like "Restart and it magically works again".
Well, 9 out of 10 times people have this issue like the OP it is because THE IP-ADDRESS IS ALREADY IN USE.
ANSWER
There could be 2 ip-addresses that are in use. Both of them you can find by:
1) Right-clicking on the start-up project
2) Click on "Properties"
3) Click on the "Debug" tab
Here you see your "App URL" and your "SSL URL".
If your "App URL" is in use, just change it there and save it and it should work again.
If your "SSL URL" is in use, close down VS, delete the "applicationhost.config" file in the hidden .vs folder of your project and open VS up again.
The solution that worked for me was to:
Close the VS project
In File Explorer, navigate to the project and delete the entire ".vs" folder
Restart the project
Run as "Debug"
Works
Apparently, it has something to do with the "applicationhost.config" file.
Enjoy!
If you can afford to restart your machine then do it 👌, this fixed my issue after almost an hour of trying to fix this issue with no hope 🤯.
I was able to toggle this error by changing a single thing. In my ASP.Net Core 1.0 RC2 Web Application project's launchSettings.json file:
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "https://localhost:18177/",
"sslPort": 0
}
},
to
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:18177/",
"sslPort": 0
}
},
I had changed to https in an attempt to run the project using that protocol. Apparently this is not the place to make that change. I suspect it is creating multiple bindings on the same port, and IIS Express doesn't like that.
I had this same issue, but the way I fixed it was by going to the applicationhost.config and remove a port which was not added by me (IIS Express I would guess) which placed my specific port site on another port.
Here is what the config file had for my bindings:
<bindings>
<binding protocol="http" bindingInformation="*:54764:localhost" />
<binding protocol="https" bindingInformation="*:44360:localhost" />
</bindings>
I removed the first bindings item as the only port I wanted was 44360. My config file now looks like this:
<bindings>
<binding protocol="https" bindingInformation="*:44360:localhost" />
</bindings>
Now I don't see the error when I debug.
I also noticed my second API in my project had port 80 also assigned to it, I removed that as well.
delete bin and obj folders from the project folder and rebuild.
For me the problem was that an other process was using the same port. (In my case it was outlook that was using the same port as my site and thus my site couldn't start)
Yes you can change the local port, but if you are running an API or something that other applications need, you don't always want to do this.
To get a list of what applications are using what port open CMD and type "netstat -aon"
You will get a list of ports. Find the port that your site should use, or that you want to use and write down / remember the PID.
Now open task manager and click on the tab 'details'. Find the process with your PID and end it. Now you should be able to start IIS Express with that port.
I just Cleaned my solution, Then Re-Built it and finally hit F5 and it worked! So simple.
I won't pretend to fully understand what MS bug creates this problem, but here is another potential solution:
In the .vs/config/applicationHost.config file, find the section for <system.applicationHost><applicationPools>. Under the pools, ensure that the managedRuntimeVersion attribute value matches the value which is in the IIS config for the system (and/or the version of the .NET framework which is installed).
For example, you may find (as I did) that the generated file has:
<add name="Clr4IntegratedAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Integrated" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />
In my case, you would replace this with:
<add name="Clr4IntegratedAppPool" managedRuntimeVersion="v4.0.30319" managedPipelineMode="Integrated" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />
Note the replacement from "v4.0" to "v4.0.30319". This resolved the issue.
What appears to be going on:
I believe that VS is generating an applicationHost.config file with "default" versions for the .NET framework, which may not match the specific version which is installed/configured on the system. You can debug/observe this issue by tracing the execution in Process Monitor, and finding the command line for iisexpress.exe. Running this command with /trace:error added yields a more informative message about a failure to preload the CLR with version v4.0. To wit:
Starting IIS Express ...
Failed while trying to preload CLR version v4.0. hr = 80131700
Failed to initalize the W3WP_HOST hr = 80131700
Process Model Shutdown called
Unable to start iisexpress.
Anyway, figured this might be helpful to someone else, since it's common enough to have multiple references online with bad information, and I've personally hit it a few times now.
For me, IIS Express was not accessible when I added iplisten on DOS Prompt like this: netsh http add iplisten MyIPAddress. I fixed it by deleting the iplisten like this: netsh http delete iplisten MyIPAddress.
If you are using VS 2017 or VS 2019 with ASP.Net Core, you can directly go to launchSettings.json under Properties folder and just change the Port number of applicationUrl key for iisSetting.
I just encountered the same problem and I killed all the "iisexpress.exe" processes that were still running. That worked for me!
Try this first if it was working and suddenly stopped:
Close Visual Studio
Kill iisexpress.exe processes
Reopen Visual Studio
Mine happens as soon as I add a new binding inside the applicationhost.config, running as administrator fixed the problem.
Just close the visual studio and reopen and execute.
It worked for me.
My solution (for .net core 2.0) was that i had forgot to add the port number in the applicationUrl, under iisExpress in launchSettings.json
"iisExpress": {
"applicationUrl": "https://localhost:50770",
"sslPort": 50770
}
I was able to resolve this by restarting my computer. I tried a few things unsuccessfully and finally gave up and restarted my computer. It has been working well now for a couple of days after I restarted. Probably the result of some process that was hung.
For me, it was a mixture of following these instructions:
Delete your web application’s .vs\applicationhost.config and try
again.
And then, perhaps most importantly, running Visual Studio with admin privileges.
I added .UseUrls("https://localhost:<some port>/") to the Program.cs. This seemed to do the trick for me!
I want to test some subdomain features in an asp.net site. I read just to edit the hosts file and add 127.0.0.1 subdomain.domain.com and that should work.
But mine seems to not. I have flushed the dns, restarted, tried new browsers and still get error 500.
When I normal run the asp.net site from Visual Studio it goes to http://localhost:17365/ . How do I get the IP address for this?
I guess I don't get the whole picture and missing some pieces.
I ran netstat -n and see that the site is running on[::1]:17365 maybe thats why its not working under ipv4?
The solution is very simple.
After you have edit your host files adding a line as:
127.0.0.1 subdomain.domain.com
you run your site, the personal web starts and you get on your browser this
http://localhost:[PortNumber]/ (eg: http://localhost:17365/ )
just change it to
http://subdomain.domain.com:[PortNumber]/ (eg:http://subdomain.domain.com:17365/)
with your hand, type it on the url on your browser, and it will work.
In visual studio when you go to run the site first change in the Website Properties > Use Dynamic PortstoFalse, then set the Port Numberto80, then run it.
It will by default launch http://localhost:80, however then in your browser visit subdomain.domain.com in your browser it will point to your debugging instance of your site (assuming you've still got that 127.0.0.1 subdomain.domain.com in your hosts file).
I just go to Project Properties > Web and under Servers, I select Use Local IIS Web server and set the Project Url to subdomain.domain.com.
Someone has registered "lvh.me" that point to 127.0.0.1
So you can use:
http://lvh.me
http://something.lvh.me
You have to configure your web server also.
Ok, you changed the hosts file. Your system (dns) knows where to go (127.0.0.1) with the host.
But your web server still know nothing about subdomain.domain.com and associates nothing with it.
When you normally start an asp.net site in Visual Studio it uses the Cassini webserver.
I'm not sure if you can configure bindings for Cassini.
My suggestion would be to configure a website or virtual directory in IIS with bindings to subdomain.domain.com, look here on how to do that: Add a binding to a site
Your hosts file should contain this:
127.0.0.1 subdomain.domain.com
The request of subdomain.domain.com will then be redirected to your Local IIS Web server (on port 80), because of the binding configuration IIS knows where to look for your website.
Within the properties of your web project in Visual Studio you can configure to use Local IIS Web server in the Web tab.
I'm not sure that the Visual Studio Development Server can handle bindings to anything other than localhost. I think the only thing you can change is the port number.
You have a couple of options.
1) Install IIS Express (or full-on IIS if you want) and configure Visual Studio to point to the site you have set up in there. You can manually set up your binding to subdomain.domain.com and it's very flexible. Take a look at this answer: Using Custom Domains With IIS Express
2) Install a port forwarder like rinetd (I think this should work if you have the entry in your hosts file). You should be able to map subdomain.domain.com:<some port number> to localhost:17365. Note that rinetd won't detect the domain you're using (just the underlying IP address which is 127.0.0.1), so it's best to use a distinct port for each project you're working on.
Goto applicationhost.config, you can find on windows tray.
Finding application.config of a current running project in IIS
Now find
<webLimits>
......
<sites>
.....
<site name="[YourProjectName]" id="[YourProjectID]">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="[Your Project Path]" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:50569:[Remove localhost from here]" />
</bindings>
</site>
.....
</sites>
......
<webLimits />
Remove localhost from bindingInformation.
Finally, Run VisualStudio as Administrator
I'm using VS 2017 and Webforms (don't say it).
In the Solution (.sln) file (in notepad) I changed the port to 8080. This was found in several properties, including VWDPort, Debug.AspNetCompiler.VirtualPath, Debug.AspNetCompiler.TargetPath, Release.AspNetCompiler.VirtualPath, and Release.AspNetCompiler.TargetPath
In the applicationhost.config file, I added:
<binding protocol="http" bindingInformation="*:8080:subdomain.domain" />
Also done in notepad. Make sure there are no duplicate or old entries anywhere in this file for bindings. After you change the port in Step 1 you may get an auto-generated duplicate entry with old bindings. Also, be sure you editing the correct applicationhost.config file. This file is in a different place depending on your version of VS.
In Powershell, run: "netsh http add urlacl url=http://subdomain.domain:80/ user=everyone"
In your hosts file (mine is in C:\Windows\System32\drivers\etc) add "127.0.0.1 subdomain.domain" to your hosts listing. You'll have to be an administrator (right-click on notepad, run as administrator)
Run VS as Administrator. This will keep the port to 80. If not run as administrator, you'll get a random port number, your .sln file will get auto-edited with this number, and you'll get duplicate bindings in applicationhost.config.
Running as Administrator is irritating, but it's the only way I could get the port to not change. Also, I tried using other ports, such as the one randomly assigned VS, but kept running into 503 errors from IIS.
Using this you could get a list of IP addresses if I add this code it resolves to
127.0.0.1 please confirm if this is what you are looking for otherwise I will remove the answer
foreach (IPAddress address in Dns.GetHostAddresses("localhost"))
{
Console.WriteLine(address.ToString());
}