본문 바로가기

▣ ASP.NET ▣/◈ MVC ◈

Visual Studio hosts 도메인 접근하여 디버깅 하기


Visual Studio 2013 버젼 이상 부터는 디버깅시 


호스트 파일에 기록한 가상의 도메인을 통해 접근이 불가능 해졌다.


IIS Express 를 이용해서 기존과 동일한 도메인 접속을 하려고하는  Bad requet  페이지가 뜬다면


아래 방법으로 해결하면 된다.





 This is the part of the post where we focus on the network/server part of your website.

In Visual Studio 2015, we need to change how IIS Express runs your development environment.

  1. In Visual Studio 2015, right-click on the solution file.
  2. Select 'Open Folder in File Explorer'
  3. Go to the containing folder and look for a .vs folder.
  4. Inside, there will be a config folder containing an applicationhost.config file.
  5. Open it in your favorite text editor (I use Notepad++)
  6. Under the Configuration/system.applicationHost/Sites, you should see your site in bindings with a port and localhost.
    <binding protocol="http" bindingInformation="*:38254:localhost" />
    
  7. Duplicate this line and add your subdomain to this binding.
    <binding protocol="http" bindingInformation="*:38254:m.localhost" />
    
  8. Save this file and reload your project.

That was to configure your site in Visual Studio.

Now we need to head to our Hosts file to modify that as well.

  1. Go to C:\Windows\System32\Drivers\Etc in File Explorer.
  2. Open the HOSTS file (it has no extension)
  3. At the bottom of the hosts file, add the following two lines.

    127.0.0.1    localhost
    127.0.0.2    m.localhost

  4. Save the file.

Now we can run our Visual Studio and see our subdomain actually run.

NOW WHAT?!

When we run Visual Studio, we get a problem with launching the IIS Express Web Server.

Visual Studio Error - Access Is Denied

"Unable to Launch the IIS Express Web Server."? Access is denied?!?

Hmm...

It seems that you need to give Visual Studio 2015 Administrative rights to use subdomains.

Well, let's get to it.

  1. In Windows 10, I have my Visual Studio 2015 pinned to my taskbar. Right-click on the Visual Studio 2015 icon.
  2. On the context menu, right-click on the "Visual Studio 2015" link.
  3. In the secondary context menu, there will be "Open", "Run as Administrator", "Unpin from Taskbar", and "Properties." Click on Properties.
  4. Click the "Advanced..." button.
  5. Make sure the option "Run as Administrator" is checked. If not, check it.
  6. Click OK.
  7. Click Apply and accept the changes.
  8. Click OK one last time to save the changes.
  9. Run Visual Studio 2015 and load your subdomain project.

OK, NOW we can run our site.

My Simple Mobile Web Page

As you can see my "mobile page" isn't too fancy, but the key thing here is the subdomain






모든 정보는 공유되어야 한다 - 코딩하는녀석