How can I solve HTTP “404” and “405” error msgs?

北城以北 提交于 2019-11-27 08:05:34

问题


Are HHTP "404" and "405" errors a step in the right direction following "400" Errors?

After changing my applicationhost.config file, based on step 3 in this article, from this:

<site name="HHS.Web" id="2">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="C:\project\git\CStore\HHS.Web" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:21608:localhost" />
        <binding protocol="http" bindingInformation="*:21608:shannon2" />
    </bindings>
</site>
<site name="HHS.API" id="4">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="C:\project\git\CStore\HHS.API" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:21609:localhost" />
        <binding protocol="http" bindingInformation="*:21609:shannon2" />
    </bindings>
</site>

...to this:

<site name="HHS.Web" id="2">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="C:\project\git\CStore\HHS.Web" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:21608:" />
    </bindings>
</site>
<site name="HHS.API" id="4">
    <application path="/" applicationPool="Clr4IntegratedAppPool">
        <virtualDirectory path="/" physicalPath="C:\project\git\CStore\HHS.API" />
    </application>
    <bindings>
        <binding protocol="http" bindingInformation="*:21609:" />
    </bindings>
</site>

...and restarting IIS Express after this rigamarole (step 4 in the same article referenced above):

....I get when running may app, instead of my previous err ("400 - Bad Request") a different but more common problem: "404 - Not Found"

However, if I enter the URL into IE on the handheld device and run it, I get, "405 - Resource Not Allowed"

Does anybody know how to solve this dilemma / can anybody see a problem with what I'm doing here?

UPDATE

As to testing various URLs from the PC's (Chrome) browser, here are what I tried and their results:

// hostname / machine name:
"http://shannon2:21608/api/inventory/sendxml/bla/bla/bla" gives me:

HTTP Error 503. The service is unavailable.

// IP Address:
"http://192.168.125.50:21608/api/inventory/sendxml/bla/bla/bla" gives me:

<Error>
<Message>
The requested resource does not support http method 'GET'.
</Message>
</Error>

// locohost:
"http://localhost:21608/api/inventory/sendxml/bla/bla/bla" gives me the same response as using the IP Address (192.168.125.50) above.

// locohost as IP Address
"http://127.0.0.1:21608/api/inventory/sendxml/bla/bla/bla" also gives me the same response as using the IP Address (192.168.125.50) or localhost as shown above.

UPDATE 2

Trying to access the resource via the (IE) browser from the handheld device:

Using 127.0.0.1 within the URL causes the browser to respond with "Cannot find server or DNS error"

Using 192.168.125.50 (my PC's IP Address) responds with "HTTP 405 - Resource not found"

UPDATE 3

In the Gretelman post referenced in the answer (here) it says to do this:

netsh http add urlacl url=http://hanselman-w500:80/ user=everyone

...from a command prompt; which, in my case, would be:

netsh http add urlacl url=http://shannon2:80/ user=everyone

But doesn't that only open attempts to access port 80? I need to access the port the REST Web API method expects, namely 21608...

Should I be doing this:

netsh http add urlacl url=http://shannon2:21608/ user=everyone

?

UPDATE 4

I can perform the following at a command prompt with no errors:

iisexpress.exe site:"HHS.Web"

It is shown as running in IIS Express -- actually, HSS.Web was up prior to running that command (as I could see by right-clicking the IIS Express taskbar icon and selecting "Show All Applications"), along with HHS.API, but I ran it to see if it would return any err msgs, according to what is suggested here

UPDATE 5

As a follow-up to Update 3 in particular, it was either this:

netsh http add urlacl url=http://shannon2:80/ user=everyone

...or this:

netsh http add urlacl url=http://shannon2:8080/ user=everyone

...that did the trick - I am now finally able to hit the breakpoint on the server from the handheld after running those commands (opening up ports 80 and 8080 to the masses using my machine's hostName). Which was necessary, or whether they both were, I don't know. I had already added the commands for "21608" and "21609" so they were not the solution:


回答1:


When considering exposing connections to your IIS Express App Instances over your network/domain, you'll have to modify HTTP.SYS and your firewall inbound rules.

Also, I recommended that you use your computer name in your binds.

Here is a reference article covering this configuration, as well as other considerations: http://www.hanselman.com/blog/WorkingWithSSLAtDevelopmentTimeIsEasierWithIISExpress.aspx

The article covers giving external traffic access to IIS Express instances on the standard port 80 using two methods/process (labeled Easy & Ninja/Hard). It also covers the process of trusting self-signed certificates and ASP.NET URL rewrite rules for accessing and handling connections over https (SSL) to your app instances.

It's quite verbose, and I'll probably update this answer with that information if it provides you with the information you require. (which I presume it will)..

EDIT:

It would seem the most appropriate article covering your issue (that you resolved at this point) was [ http://www.iis.net/learn/extensions/using-iis-express/handling-url-binding-failures-in-iis-express ], as referenced by the SO Post [ Configure IIS Express for external access to VS2010 project ].



来源:https://stackoverflow.com/questions/25878787/how-can-i-solve-http-404-and-405-error-msgs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!