httphandler 共享托管部署
我在共享虚拟主机上有 httphandler。 有用。
此 httphandler 的 httphandler webapp(虚拟)目录没有 web.config 整个共享用户的网站都有 web.config,只有一个未注释的语句:
<compilation defaultLanguage="c#" debug="false"/>
现在,我将其更改为:
<system.web>
<urlMappings enabled="true">
<add url="~/CheckLoad" mappedUrl="~/BackupLicense.ashx?key=CheckLoad"/>
<compilation defaultLanguage="c#" debug="false">
</compilation>
</system.web>
This(*) 在本地工作(在 VS2008 内部网络服务器上) 但不在共享主机上。
我想念什么? (*) 表示调用 [1a],它仅在本地工作,但在共享主机上它给出 “找不到页面”“HTTP 错误 404”
[1a] 调用方式为: http://www.MySharedSite.com/CheckLoad (除了随时随地工作 [1b] http://www.MySharedSite.com/BackupLicense.ashx?key=CheckLoad
I have the httphandler on shared webhosting.
It works.
The httphandler webapp (virtual) dir of this httphandler does not have web.config
and the whole shared user's website has web.config with only one uncommented statement:
<compilation defaultLanguage="c#" debug="false"/>
Now, I change it to:
<system.web>
<urlMappings enabled="true">
<add url="~/CheckLoad" mappedUrl="~/BackupLicense.ashx?key=CheckLoad"/>
<compilation defaultLanguage="c#" debug="false">
</compilation>
</system.web>
This(*) works locally (on VS2008 internal webserver)
but not on shared hosting.
What do I miss?
(*) means calling [1a], which works only locally but on shared hosting it gives
"The page not found" "HTTP Error 404"
[1a] Calling as:
http://www.MySharedSite.com/CheckLoad
(additionally to always and evertwhere working
[1b] http://www.MySharedSite.com/BackupLicense.ashx?key=CheckLoad
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
内置 Web 服务器以及 IIS6 和 7 上处理 URL 的方式存在一些细微差别。您需要了解共享主机上运行的 IIS 版本。
具体来说,IIS6 不支持未将扩展名映射到 aspnet_isapi.dll 的 URL - 并且由于您没有使用 URL 的扩展名,因此可能会出现这种情况。
如果您的主机使用集成管道模式的 IIS7,您可能需要配置系统.webServer 部分包含您的 url 映射,而不是 system.web。 (另请参阅此问题了解区别)。
编辑
我在评论中看到您的虚拟主机正在使用 IIS6。然后您需要请求您的虚拟主机允许 ASP .NET 处理 /Checkload URL。另一种简单的方法是在 url 末尾使用 .ashx;因为 .ashx 扩展名已在标准配置中映射到 ASP .NET。
There are some subtle differences in how URL's are handled on the built-in webserver and on IIS6 and 7. You need to know the version of IIS running on your shared host.
Specifically, IIS6 does not support URL's without the extension being mapped to aspnet_isapi.dll - and since you are not using an extension for the URL, this could be the case.
If your host is using IIS7 with integrated pipeline mode, you propably need to configure the system.webServer section with your url mapping, instead of system.web. (Also, see this question for an explanation of the difference).
Edit
I see in the comments your webhost is using IIS6. Then you need to ask your webhost to allow the /Checkload URL to be processed by ASP .NET. Another easy way to make it work would be to just use .ashx on the end of the url; since the .ashx extension is already mapped to ASP .NET in the standard configuration.