我只是在使用ASP.Net 2.0干预C#中RESTful Web服务的方式,并且已经管理(通过类库,对前者生成的dll的引用以及对web.config的一些调整)哄骗这样的URI格式:

http:// localhost / DevelopmentProject / testhandler /?input = thisismyinput

不显着地只是将输入作为一段文本返回,并带有启发性前缀“Your Input Was:”

我的印象是,我可以让URI进一步得到更多的内容:

http:// localhost / DevelopmentProject / testhandler / thisismyinput

并且有相同的结果,但不知道如何摆脱讨厌的“?input ="”

我的web.config的httphandlers部分的条目是(添加空格以显示代码):

< add verb =" *"路径= QUOT; testhandler / *" type =" HandlerLib.testhandler,HandlerLib" />

我在本地计算机上运行IIS 5.1,这会引入问题吗?

基本上我哪里出错?

感谢。

有帮助吗?

解决方案 3

我有点被骗了。

尝试:

我关于如何解决它的文章

其他提示

一种解决方案是使用UrlRewriting将Url重写为您需要的内容。

我使用 http://urlrewriter.net/ 来完成我的所有重写,你可以设置类似的东西在你的场景中

<rewriter>
   <rewrite 
     url="DevelopmentProject/testhandler/([\w]+)" 
     to="DevelopmentProject/testhandler/?input=$1" />
</rewriter>

这将保持“http:// localhost / DevelopmentProject / testhandler / thisismyinput”在您的浏览器地址栏中,处理为“http:// localhost / DevelopmentProject / testhandler /?input = thisismyinput&quot;”

您可以使用 URLRewriter.net 之类的内容实施网址重写 那会让你使用你提到的语法。

更改您的配置:    &LT;添加动词=&quot;&quot;路径= QUOT; testhandler /&QUOT; type =&quot; HandlerLib.testhandler,HandlerLib&quot; /&gt; 至:    &LT;添加动词=&quot;&quot;路径= QUOT; testhandler / *&QUOT; type =&quot; HandlerLib.testhandler,HandlerLib&quot; /&gt;

在处理程序的ProcessRequest函数中查看Request.PathInfo的值 使用像 http:// localhost / DevelopmentProject / testhandler / thisismyinput 这样的网址。

如果不这样做,请确保IIS 5.1将所有请求路由到aspnet_isapi.dll。 (虽然它似乎已经存在)这就是“配置......”。按钮&gt; “App Mappings” IIS中虚拟目录中的选项卡。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top