How to debug ASP.NET or Webservices applications on IIS

Asked

Viewed 1,822 times

2

I need to debug my application that consumes a Webservice and I would like to be able to debug Webservice in one Visual Studio window and the application in another, but I can’t make local connection from the Android emulator to the local machine.

How can I debug the Webservice that is being consumed on my own development machine or on a test server?

1 answer

2

First it is necessary that Webservice is running on a local IIS. The Visual Studio development server does not allow remote, local connections and the Android emulator acts as another machine accessing over the network.

Installing IIS on your machine

Windows 7 Home Premium, Home Basic or Home Starter machines

  • Ensure that your user is a member of the machine administrator group
  • Click on Iniciar and in Painel de Controle
  • In the Painel de Controle, click on Programas and in Ativar ou desativar recursos do Windows
  • In the Windows Features dialog box, click Serviços de Informações da Internet
  • Ensure that options are marked: ASP.NET, Recursos de Desenvolvimento de Aplicativos and Ferramentas de Gerenciamento da Web and then click on OK.

Windows 8 and Windows 8.1 machines

  • Press Windows + R and type appwiz.cpl
  • Click on Ativar ou Desativar recursos do Windows
  • In the Windows Features dialog box, click Serviços de Informações da Internet
  • Ensure that options are marked: ASP.NET, Recursos de Desenvolvimento de Aplicativos and Ferramentas de Gerenciamento da Web and then click on OK.

Serviços de Informações da Internet em Recursos do Windows

Using command prompt in Windows 7, 8 and 8.1

At command prompt (press Windows + R and type cmd.exe), type everything in one line:

start /w pkgmgr /l:log.etw /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;
IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;
IIS-HttpRedirect;IIS-ApplicationDevelopment;IIS-ASPNET;IIS-NetFxExtensibility;
IIS-ASP;IIS-CGI;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-ServerSideIncludes;
IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;
IIS-HttpTracing;IIS-CustomLogging;IIS-Security;IIS-BasicAuthentication;
IIS-URLAuthorization;IIS-RequestFiltering;IIS-IPSecurity;IIS-Performance;
IIS-HttpCompressionStatic;IIS-HttpCompressionDynamic;IIS-WebServerManagementTools;
IIS-ManagementConsole;IIS-ManagementScriptingTools;IIS-ManagementService;
IIS-IIS6ManagementCompatibility;IIS-Metabase;IIS-WMICompatibility;IIS-LegacyScripts;
IIS-LegacySnapIn;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;
WAS-ConfigurationAPI

Enabling the ASP.NET project for debugging

  1. In the project properties go Debuggers and check the option ASP.NET and mark Use Local IIS Server Note: You may need to uncheck the IIS Express

Opções do projeto

  1. In the web.config find the element configuration/system.web/compilation and add an attribute debug="true"
<configuration>
    ...
    <system.web>
        <compilation
            debug="true"
            ...
           >
            ...
        </compilation>
    </system.web>
</configuration>

Publishing the project on IIS

Creating the site to run the project

  • Perform the IIS Manager
    • Painel de Controle > Ferramentas Administrativas > Internet Information Services
    • Press Windows + R and type inetmgr
  • Set up the default website by clicking Propriedades right click on the site option
    • Type a description
    • Check the option Todos (não atribuídos) for configuration of Ips
    • Modify the TCP port if necessary
    • Click on the 'Home Directory' tab and specify a local directory for the site
    • Give read access to the directory

Configuração do site no IIS

Publishing by Visual Studio

To publish the site you need Visual Studio to upload the compiled/processed files to the folder you specified earlier. You can do it this way:

  • Click on Build> Publish or Publish Website to publish only the final files
  • Create a post profile
  • Marque File System as a method of publication
  • In the settings mark Debug

Note: Settings may not appear in some versions of Visual Studio

Publicação do Website no Visual Studio

Connecting Visual Studio to local or remote IIS for debugging

If you correctly marked the project with Use Local IIS Server and canceled Use IIS Express Visual Studio must be debugging correctly, but if this doesn’t happen for some reason, follow the following steps:

  • Ensure that Visual Studio is running as an Administrator (Run as Administrator, right click options when executing it)
  • Ensure that the IIS is being executed by the administrative panel Internet Information Services
  • Press Ctrl + Alt + P and then press w
  • Select the process w3wp.exe
  • Ensure that Common Language Runtime is selected in Choose the program types that you want to debug or Managed Code in Attach to depending on the version of Visual Studio
  • Press the button Attach

Debugando o processo do IIS

Browser other questions tagged

You are not signed in. Login or sign up in order to post.