AJAX WebMethod的通话MVC3返回404 [英] AJAX Webmethod call returns 404 on MVC3

查看:135
本文介绍了AJAX WebMethod的通话MVC3返回404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用EXTJS 4,并通过在一个.aspx页面的codebehind一个AJAX调用一个WebMethod加载我的店已经。这种方法已经为我所有的项目,直到我想我EXTJS 4的工作移植到一个MVC3项目。我的电话正在返回404。

的关键部分是,该项目(和EXTJS4的WebMethod调用)的作品在我的同事的机器 - 只有我的机器是受这种404的错误。任何的WebMethod调用,无论是1他们还是我写的,回报为资源未找到。这是怎么回事?

有些code是否有帮助: 要装入存储:

  Ext.define('pr.store.Store项',{
    延伸:Ext.data.Store,
    型号:pr.model.Model项,
    每页:200,
    groupField:GROUPID,
    自动加载:{params:一个{开始:0,上限:200}},
    代理: {
        类型:阿贾克斯,
        //从JSON文件中的数据现在
        标题:{接受:应用/ JSON,文字/ javascript中,* / *; Q = 0.01,内容类型:应用/ JSON的;字符集= UTF-8},
        网址:/Project/Data.ashx/GetData,
        读者: {
            类型:JSON,
            根:d.objects,
            totalProperty:d.totalCount
        },
        extraParams:{
            其中:Ext.en code(新的Array(''))
            ,区别:真
            ,模式:0
        }
    }
});
 

的WebMethod

  [System.Web.Script.Services.ScriptMethod(ResponseFormat = System.Web.Script.Services.ResponseFormat.Json,UseHttpGet =真)
 [System.Web.Services.WebMethod]
 公共静态对象的GetData(INT开始,诠释极限,字符串[],其中,布尔差,INT模式)
 {
     // code
 }
 

解决方案

可以有很多不同的东西。启动与IIS的配置错误。如果你把这个网址到浏览器中 - 你明白什么

I've been using EXTJS 4 and loading my stores through an AJAX call to a Webmethod on the codebehind of an .aspx page. This method has worked for all of my projects until I tried porting my EXTJS 4 work into a MVC3 project. My calls are now returning 404.

The key part is that the project (and the EXTJS4 webmethod calls) works on my colleagues' machines - only my machine is affected by this '404' error. Any Webmethod call, be it one of theirs or written by me, returns as 'Resource Not Found'. What's going on?

Some code if it helps: To Load the Store:

Ext.define('pr.store.Store-Items', {
    extend: 'Ext.data.Store',
    model: 'pr.model.Model-Items',
    pageSize: 200,
    groupField: 'groupID',
    autoLoad: { params: { start: 0, limit: 200 } },
    proxy: {
        type: 'ajax',
        //get data from json file for now
        headers: { 'Accept': 'application/json, text/javascript, */*; q=0.01', 'Content-Type': 'application/json; charset=utf-8' },
        url: '/Project/Data.ashx/GetData',           
        reader: {
            type: 'json',
            root: 'd.objects',
            totalProperty: 'd.totalCount'
        },
        extraParams: {
            where: Ext.encode(new Array(''))
            , difference: true
            , mode: 0
        }
    }
});

WebMethod

 [System.Web.Script.Services.ScriptMethod(ResponseFormat = System.Web.Script.Services.ResponseFormat.Json, UseHttpGet=true)]
 [System.Web.Services.WebMethod]
 public static object GetData(int start, int limit, string[] where, bool difference, int mode)
 {
     //Code
 }

解决方案

Can be a lot of different things. Starting with wrong configuration of IIS. If you put this URL into browser - do you get anything.

这篇关于AJAX WebMethod的通话MVC3返回404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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