与POST数据的默认浏览器C#打开网页 [英] C# Open web page in default browser with post data

查看:191
本文介绍了与POST数据的默认浏览器C#打开网页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我相信这一定是被回答过了,但我不能找到一个解决办法,所以我想我可能会误解其他民族的解决方案或试图做一些愚蠢的,但在这里我们去。



我写了2010年的前景在C#中的加载项,其中用户可以在功能区中单击一个按钮并提交邮件内容到网站上。当他们点击该按钮的网站应在默认浏览器中打开,从而使他们能够回顾一下刚刚提交,并用它在网站上进行互动。我能够做到这一点使用查询字符串在URL中使用:

  System.Diagnostics.Process.Start(HTTP:// www.test.com?something=value); 



但可以提交和杂乱的URL阻止我从下面的数据量的限制通过这种方法。我想用一个HTTP POST这个,因为它显然是更合适的。但是,我似乎已经找到了这样的方法不能提交后的数据后,打开浏览器的页面了:



http://msdn.microsoft.com/en-us/library/debx8sh9.aspx



总结;用户需要能够单击Outlook功能区上的按钮,有Web浏览器打开并显示已通过邮寄提交的电子邮件的内容。



< STRONG>编辑:



好吧,我发现了一个办法做到这一点,其漂亮的fugly但它的工程!只需创建一个临时的.html文件(也就是那么作为上述启动)含所有数据隐藏字段的表单,并将它提交了页面加载使用javascript。



我真的不喜欢这个解决方案,因为它依赖于JavaScript(我有一个提交按钮只是柜面)和好像有点bodge的,所以我还是很希望有人在这里会拿出更好的东西。


解决方案

Dropbox的客户端不作为你在编辑提到的相同的方式。 ,但也做了一些混淆,即它XOR运算通过URL提交的哈希值数据



下面是具体步骤的Dropbox是如何做的:




  1. 在应用:创建一个可用于在dropbox.com

  2. 在应用
  3. 来授权令牌:转换令牌十六进制字符串(A)

  4. 在应用:创建相同长度的安全随机十六进制字符串(b)

  5. IN-应用:计算C = A XOR b

  6. 在应用:创建具有以下功能临时HTML文件:


    1. 包含值b隐藏输入字段。

    2. 系统提交形式隐藏输入字段必要登录dropbox.com。

    3. 系统JS功能读取从URI的哈希值,为b异或,并把结果写入隐藏字段的提交表单。

    4. 从URI删除哈希值。

    5. 提交形式


  7. 在应用:打开与标准浏览器的临时HTML文件,并添加C作为哈希值的URI的结尾。

  8. 如果你的浏览器中打开HTML文件,它计算从隐藏的输入字段的验证令牌和URI中的哈希值,并打开下拉框


现在.COM。而由于点5.4。你是不是能够打在你的浏览器后退按钮再次登录因为散列IST走了。


I am sure this must have been answered before but i cannot find a solution, so i figure i am likely misunderstanding other peoples solutions or trying to do something daft, but here we go.

I am writing an add-in for outlook 2010 in C# where a user can click a button in the ribbon and submit the email contents to a web site. When they click the button the web site should open in the default browser, thus allowing them to review what has just been submitted and interact with it on the website. I am able to do this using querystrings in the url using:

System.Diagnostics.Process.Start("http://www.test.com?something=value");

but the limit on the amount of data that can be submitted and the messy urls are preventing me from following through with this approach. I would like to use an http post for this as it is obviously more suitable. However, the methods i have found for doing this do not seem to open the page up in the browser after submitting the post data:

http://msdn.microsoft.com/en-us/library/debx8sh9.aspx

to summarise; the user needs to be able to click the button in the outlook ribbon, have the web browser open and display the contents of the email which have been submitted via post.

EDIT:

Right, i found a way to do it, its pretty fugly but it works! Simply create a temporary .html file (that is then launched as above) containing a form with hidden fields for all the data, and have it submitted on page load with javascript.

I don't really like this solution as it relies on javascript (i have a submit button just incase) and seems like a bit of a bodge, so i am still really hoping someone on here will come up with something better.

解决方案

The Dropbox client does it the same ways as you mentioned in your EDIT. But it also does some obfuscation, i.e. it XORs the data with the hash submitted via the URL.

Here are the steps how Dropbox does it:

  1. in-app: Create a token that can be used to authorize at dropbox.com.
  2. in-app: Convert token to hex string (A).
  3. in-app: Create a secure random hex string (B) of the same length.
  4. in-app: Calculate C = A XOr B.
  5. in-app: Create temporary HTML file with the following functionality:

    1. A hidden input field which contains value B.
    2. A submit form with hidden input fields necessary for login to dropbox.com.
    3. A JS function that reads the hash from URI, XORs it with B and writes the result to the submit forms hidden fields.
    4. Delete hash from URI.
    5. Submit form.

  6. in-app: Open the temporary HTML file with the standard browser and add C as hash to the end of the URI.

Now if your browser opens the HTML file it calculates the auth token from the hidden input field and the hash in the URI and opens dropbox.com. And because of Point 5.4. you are not able to hit the back button in your browser to login again because the hash ist gone.

这篇关于与POST数据的默认浏览器C#打开网页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆