如何调试ASP.NET中的一个WebMethod [英] How to debug a WebMethod in ASP.NET

查看:991
本文介绍了如何调试ASP.NET中的一个WebMethod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有如下的的WebMethod 在我的 fileName.asmx.cs 文件。

I have the following WebMethod in my fileName.asmx.cs file.

[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string GetData(string value)
    {
        //-----
        //Respective code querying the database
        //-----
    }

下面是使用各自的Ajax调用 的jQuery

Here is the respective ajax call using jQuery

getData: function (type) {        
        var response = "";
        $.ajax({
            type: "POST",
            dataType: 'json',
            url: "../GetData",
            data: '{value:' + type.toString() + '}',
            async: false,
            contentType: "application/json; charset=utf-8",
            success: function (msg) {
                console.log('succes', msg)
                response = msg;
            }
        });
        return response.d;
    }

我加入我的的WebMethod 断点调试,但它是不是踏进了。
我试图做到这一点我的本地主机:2133,参考一些SO答案我也试过并附以下过程,但没有成功。

I add breakpoints in my WebMethod for debugging, however it is not stepping into it. I'm trying to do this my localhost:2133, With reference some SO Answers I also tried attaching the following process but no success.

无需调试,我没有能够解决的错误,因为我已经浪费了几个小时,我张贴在这里。

Without debugging I'm not able to solve errors, Since I already wasted a couple of hours I posted here.

有人能指导我(情侣截图会更有帮助)如何调试一个WebMethod在ASP.NET?

Can someone guide me(couple of screenshots will be more helpful) how to debug a WebMethod in ASP.NET?

更新1:我也试过把 Console.WriteLine() 的WebMethod 。但在VS2012的输出屏幕显示什么。

Updates 1: I also tried putting Console.WriteLine() in the WebMethod. But nothing shown in the output screen of VS2012.

更新2:我收到错误会建立文件,但该网站是在我的本地主机。这个错误是导致我麻烦调试的WebMethod?或者是明确的。

Updates 2: I'm getting error will building the file, but the site is up in my localhost. Is this error is causing me trouble to debug the WebMethod? or to be clear

只有干净code(没有错误)只能进行调试?

推荐答案

一个长期的斗争(一整天)后,我发现是什么导致了我的问题。为什么我无法调试的原因是因为2的错误。

After a long struggle (a whole day), I found what was causing me the issue. The reason why I was not able to debug is because of 2 errors.

我没有考虑解决,因为它是一个纯粹的许可证错误。的现在我才知道,只有干净的(无差错code)的Web服务可以进行调试。

I didn't consider to fix because it was a merely a licence error. Now I learnt that only clean (error free code) Web Service can be debugged.

而对于通过IIS调试,我用的 的w3wp.exe 进程附加到它。

Whereas for debugging via IIS, I used w3wp.exe process attaching to it.

这对我帮助很大 http://forums.iis.net/t/1154992.aspx

这篇关于如何调试ASP.NET中的一个WebMethod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆