需要有关 HttpWebrequest 的帮助
大家好,我有同样的问题,我正在寻求解决它。这是详细信息我有两个网站 WebsiteA 和 WebSiteB (WebsiteB 不在我的控制范围内,对我来说是一种黑匣子。)。
两个网站都有单独的登录页面 我有一个用户列表,网站B的密码,我存储在数据库中。 我想要一种通用的登录页面。如果用户登录A网站后想访问B网站,则无需再次输入登录名和密码信息。 我不能碰B网站的代码。它已经部署并运行。 在 websiteB 的登录表单中,它们有一个用户 ID 文本框和密码文本框以及一个登录按钮。该按钮不是提交按钮。它有一个单击事件,该事件调用一个函数来验证用户。这不是一个简单的帖子。 WebsiteB 有一个网页,该网页具有不同的框架。登录成功后。这些页面不会转到任何其他页面,它保留在同一页面上,但加载不同的框架。 据我所知。我可以使用 httpwebrequest 类。但面临以下问题。
无法点击按钮。 Response.Redirect 不起作用。 看来 WebsiteB 没有在 cookie 中存储任何内容,因为 cookie 总是返回一个空字符串,
如果有人可以帮助我,我真的很感激。 我如何使用response.Redirect。当我重定向时,它会显示相同的登录页面。
HI Guys I have the same issue and I am looking to solve it. Here is detail I have two web sites WebsiteA and WebSiteB (WebsiteB is not in my control, A type of black box for me.).
Both websites have seprate login page
I have alist of users,password of websiteB which I stored in database.
I want a kind of common login page. If user is login to websiteA and he want to go to websiteB, he dont have to enter the login and password information again.
I can not touch the code of websiteB. it's alredy deployed and runing.
In websiteB in login form they have a Userid textbox and Password textbox and and a login Button. This butoon is not a submit button. It has a click event which calls a function to validate the user. it's not a simple post.
WebsiteB has one webpage which has different frames. After login sucessfull. The pages doesnt go to any other page it remain on the same page but load the different frame.
According to my knowledge. I can use httpwebrequest class. But faceing the following problem.
Can not click the button.
Response.Redirect does not work.
It seems that WebsiteB is not storing any thing in cookies as cookies always return me a empty string
I really appriciate if anyone can help me on it.
How Can I use response.Redirect . As when I redirect it shows me the same login page.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
在不知道网站登录如何工作的情况下,BI 无法确定,但在某些时候,我确信有一个带有登录信息的帖子。我对解决方案的最佳猜测是尝试模仿站点 B 在登录时所做的操作。使用 firebug 并观察发送的内容和返回的内容。你必须模仿这种行为。
它可能是这样的:
POST 凭据到站点 B 进行验证,返回验证结果。
如果验证良好,则使用验证结果中的令牌重定向到站点 B。
同样,在不了解站点 B 的情况下,我无法说,但无论它做什么,它可能会使用普通的 http,因此您可能可以复制它。也就是说,站点 B 可能会通过仅接受来自某些 URL 的登录来禁止您登录。
至于使用 HttpWebRequest,我认为您会发现最好只使用从站点 A 提交的隐藏表单。
Without knowing how login works to site B I could not say for sure, but at some point, I'm sure there is a post with login information. My best guess at a solution would be try to imitate what site B does on login. Use firebug and watch what gets sent, and what is returned. You'll have to mimic this behavior.
It may be something like:
POST credentials to site B for verification, returns verification result.
If verification is good, use token from verification result to redirect to site B.
Again, without knowledge of site B, I could not say, but whatever it does, it likely does using normal http, thus you can probably duplicate it. That said, site B may forbid you from logging in by only accepting logins from certain URLs.
As for using the HttpWebRequest, I think you'll find you're better off just having a hidden form which you submit from site A.
HttpWebRequest 将在 WebsiteA 的服务器上执行。即使您向 WebsiteB 执行正确的 HttpWebRequest POST,您也无法将该会话 cookie 传递到用户的浏览器,除非立即重定向到 WebsiteB。
您可能还想研究其他单点登录技术 - 您所描述的方法将不起作用。
A HttpWebRequest will execute on the server of WebsiteA. Even if you execute the correct HttpWebRequest POST to WebsiteB, you won't be able to pass that session cookie to the user's browser without also immediately redirecting to WebsiteB.
There are other single-sign-on techniques you may want to investigate - the approach you have described will not work.
嗨,我明白了。我们可以创建一个 XML 字符串并将该字符串转换为字节,然后使用 HttpWebrequest 的正常写入功能来写入 XML。
HI I figure out . We can create a string of XML and the converting the string into bytes and then use the normal write function of HttpWebrequest to Write the XML.