我正在开发一个Web应用程序,需要在客户端计算机上调用自定义注册协议。目前我对协议进行了GET,然后通过查询字符串传递参数。
是否可以对自定义注册协议执行POST操作,如果可以,我将如何在CustomProtocol.exe中提取标头信息?
这是我目前的GET解决方案
从javascript发起呼叫
Custom://startup?Function=DoSomething&Value1=Test&Value2=Test
我在自己的计算机上注册的自定义协议。
[HKEY_CLASSES_ROOT\Custom\shell\open\command]
@="\"CustomProtocol.exe\" \"%1\""
然后我编译了下面的代码来生成CustomProtocol.exe。在执行期间,URI被传递到Main方法,然后我提取查询字符串。
namespace CustomProtocol
{
class Program
{
static void Main(string[] args)
{
// Get the querystring from the URI being passed in
// Business code...
}
}
}
编辑1:
这是对自定义注册协议发布帖子时的标题。该协议只有1个arg传入其中,就像GET那样是URI。不知何故,如果我只能访问标题信息......
Request URL:http://localhost/CustomWebInvoker/Default.aspx Request Headersview source Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Content-Type:application/x-www-form-urlencoded Origin:http://localhost Referer:http://localhost/CustomWebInvoker/Default.aspx User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.78 Safari/535.11 Form Dataview URL encoded
__VIEWSTATE:/wEPDwUKMTkxMDU5NzI4OWRkBWZZppW219Muku6ZjiGZLQG5um8=
__EVENTVALIDATION:/wEWCwKz9d77DAK57evuBgLk0vuTDALl+pjzDQKB8r3PAQKk+8X1CwLLneGNCgK2gO/LCAK355HvBAKAseegDAL+ovbYDMmmPuTHB0XbFjGRG9Wl1ij5kObV
dlLanguage:English
dlApplicationMode:UpdateMode
dlCallingApplication:CSS
dlCentre:EasternCompCenter
btnFastPath:Fast Path
答案 0 :(得分:3)
NO - any custom protocol handler is basically getting its information via the commandline... there is no way to map a POST to the commandline ...如果您真的需要这样做,我建议将其实现为基于http的Web服务(WCF,SOAP / REST)......