简体   繁体   中英

ScriptMethod in ASPX page, called from browser, IIS6 Returning 404

I have code which works on the dev environment (my machine), though doesn't work on IIS6

I have a method in an ASPX page which has a footprint similar to this:

 [WebMethod()]
 [ScriptMethod()]
 public static string HelloWorld(string name)
  { 
       return 'Hi '+name;
  }    

When I look at the console on the browser, I can see my script call this method, though IIS returns a 404 not found.

The script does a http POST to this url: http://mydomain.com/myPage.aspx/HelloWorld

I am guessing it has something to do with mime types on IIS?

Found the solution to this, The problem was caused by two things.

Firstly, I needed to add this to the Web.Config

<webServices>
    <protocols>
        <add name="HttpGet"/>
        <add name="HttpPost"/>
    </protocols>
</webServices>

Then , the other issue was the use of a tool for url rewriting called UrlRewritingNet (http://www.urlrewriting.net/149/en/home.html)

One of the ways to configure this module, is to put in in IIS6 as an ISAPI filter , matching a wild card * , so if no file extension was matched, this filter would run the query.

The way I got around the second problem was to do an XML query to my service, and not a json one. Which then uses a url with a file extension when making the call.

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM