简体   繁体   English

将值发布到URL而不重定向

[英]Post values to URL without redirecting

I'm setting up an SMS service where I have to post some values, like receiver, sender and message to a specific url at provider. 我正在设置一个SMS服务,我必须在其中将一些值(例如接收者,发送者和消息)发布到提供者处的特定URL。

Pretty simple if I just add a button and in the button event I make a response.redirect("...url and url parameters with values...") 如果我只添加一个按钮,并且在按钮事件中,我会做出一个response.redirect(“ ...带有值的url和url参数...”),这非常简单

But I don't want the user to be redirected to another page when the button is clicked. 但是我不希望在单击按钮时将用户重定向到另一个页面。 I have tried to post the url to a new window with JavaScript. 我尝试使用JavaScript将网址发布到新窗口。 This is okay, but I'm running into a lot of pop-up blocking issues with the browser... 没关系,但是我在浏览器中遇到了很多弹出窗口阻止问题...

Is there any recomendations on how to accomplish that, I think it must be a pretty common way to post information to payment services and such. 关于如何做到这一点有什么建议,我认为这是将信息发布到支付服务等的一种非常普遍的方式。

Best regards. 最好的祝福。

When you need to load content in to different pages without reloading you can use local storage which is now widely supported. 当您需要将内容加载到不同的页面而不进行重新加载时,可以使用本地存储,该存储现已得到广泛支持。 Similar in a sense to cookies but much more flexible and up to date. 从某种意义上讲类似于cookie,但是更加灵活和最新。

In depth look in to Local Storage here 这里深入了解本地存储

Brief local storage demo here 在此处简要介绍本地存储演示

I can't be sure the exact method of using this with VB or C# but I am sure if you look around you will find it. 我不确定将其与VB或C#一起使用的确切方法,但是我确定如果环顾四周,您会发现它。 It is a little hard to tell your exact use case, but ultimately GET variables are loaded in to the page or script on load, s even if you manage to change or update the variable, that won't be accessed until next reload. 很难说出确切的用例,但是最终GET变量会在加载时加载到页面或脚本中,即使您设法更改或更新该变量,也要等到下一次重新加载时才能访问。

使用System.Net.WebClient,您无需进行重定向即可调用网站。

Dim result As String = New System.Net.WebClient().DownloadString("http://...") 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM