When debugging a web page which uses a file system based web service, I met an error message in Visual Studio 2008 which troubles me for a while.  Here are the steps and the solution.

1. Create a new C# file system based web site (website1)
2. Add a file system based web service web site into the solution, by file->Add->New web site. Name it webservice1.
3. In website1, add service reference to webservice1
4. In website1 default.aspx.cs file, add following to the page_load function
        ServiceReference1.ServiceSoapClient client = new ServiceReference1.ServiceSoapClient();
        Response.Write(client.HelloWorld());

5. In win2k3, add break point in service.cs HelloWorld function. In Vista, this is not a requirement.
6. F5 to debug default.aspx file, answer yes to change the website1’s web.config’s Debug=True.

7. An error message pops up:

Unable to automatically debug 'D:\...\WebSite1\'. The remote procedure could not be debugged. This usually indicates that debugging has not been enabled on the server.  See help for more information.

 

The problem is that Visual Studio didn’t change the webservice1’s web.config’s Debug=True during step 6.  I think the reason behind this is to prevent downgrading the security without proper warning.  So in order to debug it, you need to change the webservice1’s web.config debug setting yourself.

 

And don’t forget to change it back when release it.

 

VS2008调试使用了基于文件的网络服务的网页时,需将网络服务web.config中的Debug设为True

 

当我用VS2008调试一个使用了基于文件的网络服务的网页时,我遇到了一个让我花了一些时间的问题。下面是步骤和解决方法。(我是用的英文版,中文的翻译和实际VisualStudio上显示的会有出入。)

 

1. 新建一个新的C#基于文件系统的网站(website1)
2. 在解决方案中加入基于文件系统的网页服务,通过文件->添加->新网站 (file->Add->New web site)。叫它webservice1
3. website1中,加入webservice1的引用
4. website1default.aspx.cs的文件中,在page_load函数中加入
        ServiceReference1.ServiceSoapClient client = new ServiceReference1.ServiceSoapClient();
        Response.Write(client.HelloWorld());

5. 如果使用win2k3的操作系统,在service.cs文件中的HelloWorld函数加上断点。在Vista中,不需要这样做。
6. F5 来调试default.aspx 文件,当跳出将website1web.config文件改成Debug=True的问题框时,的选择

7. 遇到下面的错误信息:

Unable to automatically debug 'D:\...\WebSite1\'. The remote procedure could not be debugged. This usually indicates that debugging has not been enabled on the server.  See help for more information.

 

问题是Visual Studio在第6步时没有改变webservice1web.config文件Debug值为True。我想原因是为了安全考虑,不在用户不知情的情况下改变web.config的安全设置。所以,需要手工改变webservice1文件web.configdebug值。

 

不要忘了在发布时把debug设回成False