Development Tip

LAN을 통해 Visual Studio 디버깅 IIS Express 서버에 연결

yourdevel 2020. 10. 15. 21:50
반응형

LAN을 통해 Visual Studio 디버깅 IIS Express 서버에 연결


VS2012에서 개발 된 테스트 ASP.NET MVC3 응용 프로그램이 있습니다. 디버깅을 시작하면 .NET에 대한 요청을 통해 호스트 컴퓨터에서 앱에 액세스합니다 http://localhost:<portnumber>. 하지만 난을 통해 인트라넷에 원격 컴퓨터에서 동일한 응용 프로그램에 액세스하려고하면 http://<ip>:<portnumber>내가 얻을 HTTP error 400: Bad request. Invalid Host Name.이 모든 서버 구성에 액세스 할 수없는 IIS 익스프레스에서 실행 마찬가지로 지금까지.

이 문제를 해결할 수있는 방법이 있습니까?


최신 정보

프로세스를 더 잘 설명하는 비디오를 만들었습니다. https://youtu.be/5ZqDuvTqQVs

Visual Studio 2013 이상을 사용하는 경우이 작업을 수행하려면 관리자로 실행해야합니다.


%USERPROFILE%\My Documents\IISExpress\config\applicationhost.config(VS2015에서는 $(solutionDir)\.vs\config\applicationhost.config) 파일을 엽니 다 . 내부에는 다음과 같은 내용이 표시되어야합니다.

<site name="WebSite1" id="1" serverAutoStart="true">
    <application path="/">
        <virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:8080:localhost" />
    </bindings>
</site>

변경 bindingInformation=":8080:localhost"bindingInformation="*:8080:*"(다른 것, 내 경우에는 포트 번호, 8080).

참고 : 작동하지 않는 경우 bindingInformation="*:8080:별표를 제거 할 수 있습니다.

그런 다음 방화벽이 해당 포트에서 들어오는 연결을 허용하는지 확인하십시오. IISExpress에서 구성 파일을 다시로드하려면 시스템 또는 최소한 Visual Studio를 다시 시작해야 할 수 있습니다.

이것이 작동하지 않으면 https://stackoverflow.com/a/5186680/985284 답변을 살펴보십시오.


VisualStudio 2015 비 관리자

  1. 솔루션 디렉토리에서 파일 .vs\config\applicationHost.config에서 줄을 변경하십시오.

    <binding protocol="http" bindingInformation="*:44302:localhost" />

    ...에

    <binding protocol="http" bindingInformation=":44302:" />

    (44302는 포트)


  1. 관리자 명령 프롬프트에서 :

    나는. 관리자가 아닌 사용자가 포트에 바인딩하도록 설정

    netsh http add urlacl url=http://*:44302/ user=Everyone

    ii. 방화벽을 통해 허용

    netsh advfirewall firewall add rule name="IISExpress visualstudio app" protocol=tcp localport=44302 dir=in action=allow


  1. VisualStudio에서 디버깅 시작

iisexpress 구성 파일을 수정하는 경우를 제외하고 때로는 아래와 같은 명령을 실행해야합니다.

netsh http add urlacl url = http : // * : 49419 / user = Everyone


@Garret Fogerlie의 게시물에 댓글을 추가 할 수없고 댓글 작성자의 문제 (@ Y.Ecarri 및 @SamuelEdwinWard)에 대한 응답으로 Garret이 제안한대로 Visual Studio 2013을 사용하여 관리자 모드에서 실행하고 application.config파일.

디버그를 시작하고 동일한 오류 메시지가 표시되는 것을 확인한 후 다시 들어가서 application.configY.Ecarri의 문제처럼 내 사이트에 대한 새 항목이 생성되었음을 확인했습니다.

그래서 디버깅을 중지 하고 Visual Studio에서 내 솔루션을 열어application.config 두고 새 항목에 대해 파일을 다시 편집했습니다 . 나는 또한 단순히 *노래를 localhost완전히 제거 했기 때문에 새 항목에 대해 다음과 같이했습니다.

<binding protocol="https" bindingInformation=":44300:" />


Visual Studio를 관리자로 실행하지 않는 방법

Garret@shangkeyun의 대답모두 사용하면 Visual Studio를 관리자로 실행할 필요없이 실행중인 웹 사이트에 연결할 수 있습니다.

  1. 열다 %USERPROFILE%\My Documents\IISExpress\config\applicationhost.config
  2. 다음을 사용하여 사이트 검색 name=MySiteName
  3. 섹션 의 기존 <binding>항목을 복제 <bindings>하십시오. 이제 binding.
  4. bindingInformation에서 "localhost"부분을 제거하십시오.
  5. 이제 포트가 다음과 같다고 가정하면 다음과 같이 표시됩니다 12345.

    <binding protocol="http" bindingInformation="*:12345:localhost" />
    <binding protocol="http" bindingInformation="*:12345:" />
    
  6. 관리자가 아닌 사용자가 포트에 바인딩하도록 설정

    netsh http add urlacl url=http://*:12345/ user=Everyone
    

2019 편집 : gregmac은 VS 인스턴스를 화이트리스트에 추가하는 단계를 추가했습니다. 나는 이것이 필요하지 않았지만 어쨌든 그것을 나열합니다.

  1. netsh advfirewall firewall add rule name="IISExpress visualstudio app" protocol=tcp localport=12345 dir=in action=allow

byteit 덕분에 :

Documents / IISExpress / config에서 applicationhost.config로 이동합니다.

작업중인 특정 사이트에 대한 항목을 찾으십시오.

더하다:

<binding protocol="http" bindingInformation="*:<your site port>:*" />

기존의

 <binding protocol="http" bindingInformation="*:<your site port>:localhost" />

To achieve the solution without having VS2013 create a new website xml entry for you when you restart. You will need to run as administrator.


Some of you might spend a lot of time modifying and testing using your %USERPROFILE% directory. If you are running on VS debug, use $(solutionDir).vs\config\applicationhost.config


This is what worked for me:

  • Start the IIS Manager
  • Add a new virtual directory that points to the projects folder (C:\VSProjects in my case)
  • Select the new virtual directory within IIS manager. Select Directory Browsing from the list of options. On the right side there's a Enable button. Click it.

Now I can access my folder and project bin on the network through mypcname\VSProjects\myProj\outputBinViewer.


After the above configurations, I had to run the Visual Studio in Administrative Mode.

enter image description here


Had the a very similar issue debugging in Visual Studio Code, I solved it by adding:

"env": {
      // ...
      "ASPNETCORE_URLS": "http://*:5000" // change to the port you are using
      // ...
},

.. to launch.json

Apparently, by default it binds http protocol to 'localhost:5000', so it works with localhost but not with ip address - neither remotely nor locally.

If you are trying to hit a breakpoint by a request coming from a different computer, don't forget to check your firewall settings (and/or antivirus)

hope this helps

참고URL : https://stackoverflow.com/questions/14725455/connecting-to-visual-studio-debugging-iis-express-server-over-the-lan

반응형