我有两个网站,我使用相同的cookie登录,它工作正常。单点登录网站 - MVC 3
我遇到的问题是这两个网站在设计上看起来完全不同,我希望其中一个网站处理登录功能,另一个只需将用户名/密码发布到另一个网站并在后端创建cookie。
我有这个功能,但问题是如何通知其他网站,登录已成功或失败,实际上没有去其他网站完成登录过程?
我已经创建了类似这样的工作正常,但这是我应该如何处理另一个网站上的帖子以及我应该返回的问题作为回答困惑我的问题。
任何想法或替代解决方案都会对我有很大帮助!
[HttpPost]
public ActionResult FormPost(LogOnModel model)
{
WebRequest request = WebRequest.Create(strServer);
// Set the Method property of the request to POST.
request.Method = "POST";
// Create POST data and convert it to a byte array.
byte[] byteArray = Encoding.UTF8.GetBytes("password=" + model.Password);
// Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded";
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;
// Get the request stream.
Stream dataStream = request.GetRequestStream();
// Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close();
// Get the response.
WebResponse response = request.GetResponse();
// Get the stream containing content returned by the server.
dataStream = response.GetResponseStream();
// Open the stream using a StreamReader for easy access.
StreamReader reader = new StreamReader(dataStream);
// Read the content.
string responseFromServer = reader.ReadToEnd();
// Clean up the streams.
reader.Close();
dataStream.Close();
response.Close();
TempData["Response"] = responseFromServer;
return View();
听起来像您可以从共享的[WebService](http://msdn.microsoft.com/zh-cn/library/t745kdsh.aspx)中受益。 – jrummell 2012-03-02 15:13:24