Asp.net 我该如何解决一个问题;无法识别URL的请求格式…“;IIS中运行的web服务出错?

Asp.net 我该如何解决一个问题;无法识别URL的请求格式…“;IIS中运行的web服务出错?,asp.net,web-services,Asp.net,Web Services,在IIS中运行web服务时,我遇到以下错误: “/Inbox服务”中的服务器错误 应用请求格式为 无法识别URL的错误 以“/GetMailsInfo”结尾。 描述:未处理的异常 在执行过程中发生 当前web请求。请检查 有关堆栈跟踪的详细信息,请参阅 错误及其来源 密码 例外情况详情: System.InvalidOperationException: 无法识别URL的请求格式 出人意料地以 “/GetMailsInfo” 源错误: 生成了一个未处理的异常 在执行当前 网络请求。有关 例外的来

在IIS中运行web服务时,我遇到以下错误:

“/Inbox服务”中的服务器错误 应用请求格式为 无法识别URL的错误 以“/GetMailsInfo”结尾。 描述:未处理的异常 在执行过程中发生 当前web请求。请检查 有关堆栈跟踪的详细信息,请参阅 错误及其来源 密码

例外情况详情: System.InvalidOperationException: 无法识别URL的请求格式 出人意料地以 “/GetMailsInfo”

源错误:

生成了一个未处理的异常 在执行当前 网络请求。有关 例外的来源和位置 可以使用异常来识别 堆栈跟踪如下

堆栈跟踪:

[无效操作异常:请求 无法识别URL的格式 出人意料地以 “/GetMailsInfo”。]
System.Web.Services.Protocols.WebServiceHandlerFactory.CoreGetHandler(类型 类型,HttpContext上下文,HttpRequest 请求、HttpResponse响应) +490982 System.Web.Services.Protocols.WebServiceHandlerFactory.GetHandler(HttpContext 上下文、字符串动词、字符串url、, 字符串文件路径)+104
System.Web.Script.Services.ScriptHandlerFactory.GetHandler(HttpContext 上下文,字符串请求类型,字符串 url,字符串路径)+127
System.Web.HttpApplication.MapHttpHandler(HttpContext 上下文,字符串请求类型, 虚拟路径,字符串 路径转换,布尔值(useAppConfig) +175 System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +120 System.Web.HttpApplication.ExecuteStep(IExecutionStep 步骤、布尔值和同步完成) +155

版本信息:Microsoft.NET 框架版本:2.0.50727.42; ASP.NET版本:2.0.50727.42


有人知道我为什么会看到此错误,以及是否有办法修复此错误吗?

因为HTTP GET和HTTP POST正在尝试将以下内容添加到配置文件中:

<configuration>
    <system.web>
    <webServices>
        <protocols>
            <add name="HttpGet"/>
            <add name="HttpPost"/>
        </protocols>
    </webServices>
    </system.web>
</configuration>

我也有同样的问题。 要解决此问题,请将[ScriptService]添加到您的服务中

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Script.Services;
    using System.Web.Services;

    namespace DemosAjaxcontroltoolkit
    {
        /// <summary>
        /// Summary description for WebService
        /// </summary>
        [ScriptService] 
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        [System.ComponentModel.ToolboxItem(false)]
        // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
        // [System.Web.Script.Services.ScriptService]
        public class WebService : System.Web.Services.WebService
        {

            [System.Web.Script.Services.ScriptMethod()]
            [WebMethod]

            public string[] GetWords(string prefixText, int count)
            {
                List<string> words = new List<string>();
                words.Add("Apple");
                words.Add("Appertizer");
                words.Add("Apple tree");
                words.Add("Apple Cider");
                words.Add("Afternoon");
                words.Add("Morning");
                words.Add("Breakfeast");
                words.Add("Lunch");
                words.Add("Spider");
                words.Add("Morning");
                words.Add("Day");
                words.Add("Travel");
                words.Add("Night");
                words.Add("Car");
                words.Add("Bikes");
                words.Add("Love");
                words.Add("Good");

                //return words.Where(w => w.StartsWith(prefixText)).Take(count).ToList();

                //List<string> returnedList = words.Where(w => w.StartsWith(prefixText)).Take(count).ToList();
                return words.Where(w => w.ToUpper().StartsWith(prefixText.ToUpper())).ToArray();
            }

        }
    }
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Web;
使用System.Web.Script.Services;
使用System.Web.Services;
命名空间DemosAjaxcontroltoolkit
{
/// 
///WebService的摘要描述
/// 
[脚本服务]
[WebService(命名空间=”http://tempuri.org/")]
[WebServiceBinding(ConformsTo=WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
//要允许使用ASP.NET AJAX从脚本调用此Web服务,请取消注释以下行。
//[System.Web.Script.Services.ScriptService]
公共类WebService:System.Web.Services.WebService
{
[System.Web.Script.Services.ScriptMethod()]
[网络方法]
公共字符串[]GetWords(字符串前缀,整数计数)
{
列表单词=新列表();
文字。添加(“苹果”);
词语。添加(“开胃者”);
添加(“苹果树”);
文字。添加(“苹果酒”);
字。加上(“下午”);
字。加上(“上午”);
词语。添加(“Breakfeast”);
加上(“午餐”);
文字。添加(“蜘蛛”);
字。加上(“上午”);
字。添加(“日”);
字。加上(“旅行”);
字。加上(“夜晚”);
词语。添加(“Car”);
词语。添加(“自行车”);
加上(“爱”);
词语。添加(“良好”);
//返回words.Where(w=>w.StartsWith(prefixText)).Take(count.ToList();
//List returnedList=words.Where(w=>w.StartsWith(prefixText)).Take(count.ToList();
返回words.Where(w=>w.ToUpper().StartsWith(prefixText.ToUpper()).ToArray();
}
}
}
}
只是出于兴趣(在通过AJAX访问web服务的情况下);我发现,如果没有传递“content type”头(即使是本地/“HttpPostLocalhost”请求),则会出现问题,因此我自己传递头(例如,通过jQuery的“$.ajax()”方法,而不是不通过jQuery的“$.getJSON()”方法),而不是诉诸以下方法:


为什么他们都是残疾人?默认情况下启用了什么?使用queryString不会解决问题吗?意思是?op=getMailsinfo对于asp.net1.1 Elad Brenda,一些旧样式的asmx文件默认使用blahblah.asmx/dosomestuff之类的查询字符串。我想升级到WCF的另一个原因是,我可以发送请求,但无法从服务器接收响应,我正在从服务器中退出xml。是否需要更多的配置。可能的副本为了让谷歌更容易,错误消息的德语翻译为“unbekannets Anforderungsformat für eine URL,die unerwarte mit'/_myMethodName'endet.”。