Even though .asmx web services are becoming dinosaurs of the new .NET world of WCF. I missed the simplicity of debugging code right in visual studio without:
2- Then add WebMethod attribute to a function you want to expose in .asmx
3- Take the .svc file from your solution - copy and rename the copied file [YourOriginalWCFFile.asmx]. Open up the copied file and rename "ServiceHost" to "WebService" in the .asmx file. You will end up with a file that looks like
That's it you are done! Now you can add breakpoints in your code and fireup the .asmx file for debugging. You can turn of the .asmx service by removing the WebService and WebMethod attributes to your class and function during deployment.
- Creating a client to consume WCF service
- Attaching w3p.exe process and
- Adding break points
One quick solution: Turn WCF service into .asmx service with few lines of code, debug your code with asmx, and turn .asmx off during deployment.
Detail steps:
1- First take your WCF class and add WebService attribute to it
Code Snippet
- /// <summary>
- /// Dual mode with .ASMX and WCF
- /// </summary>
- [WebService(Namespace = "http://www.yourdomain.com/")]
2- Then add WebMethod attribute to a function you want to expose in .asmx
Code Snippet
- [WebMethod]
- public List<PageController.Page> DualFunction()
- {
3- Take the .svc file from your solution - copy and rename the copied file [YourOriginalWCFFile.asmx]. Open up the copied file and rename "ServiceHost" to "WebService" in the .asmx file. You will end up with a file that looks like
<%@ WebService Language="C#" CodeBehind="PathToCode" Class="YourClass" %>
Comments