将数据从一个控制器传递到另一个控制器,这是另一个域MVC C# [英] Pass data from one controller to another contoller which is another domain MVC C#

查看:356
本文介绍了将数据从一个控制器传递到另一个控制器,这是另一个域MVC C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想将来自Domain1中存在的一个控制器的数据发送到另一个存在于另一个Domain2中的控制器。它从某个网站重定向到这里有一些数据。我应该在mvc c#中这样做。请给我一些示例工作代码



我尝试过:



我没有尝试过任何东西!请给我一些示例代码

Hi ,

I want to send data from one controller which is present in "Domain1" to another controller which is present in another "Domain2". It some sort of redirect from that website to here with some data. I should be doing this in mvc c#. Please give me some sample working code

What I have tried:

I did not tried anything!!! Please give me some sample code

推荐答案

尝试使用WebClient或HttpRequset从App1 Post requset创建

并发布对象。

在另一边App2创建post方法来获得这个按摩:



[HttpPost]

公共actionResult GetDataFromApp1(DataObject数据) )

{

//你的逻辑

}



***如果您不在网上隐私,您可以加密您的数据。

或craete过滤器此操作方法的属性,即只有App1主机可以调用此方法。
try to create from App1 Post requset using WebClient or HttpRequset
and post Object .
In the other side App2 create post method that get this massage:

[HttpPost]
Public actionResult GetDataFromApp1(DataObject data)
{
//Your Logic
}

*** You can encrypte your data if you wont privacy on the web.
or craete filter Attribute to this action method that say only App1 Host can Invoke this method .


将您的数据类移动到外部dll,然后引用两个位置,即类Acme位于您的命名空间myspace.one中,您希望它在myspace.two中,然后将其移动到myspace.types并在myspace.one和myspace中引用它们.two他们可以知道并处理相同的类型。



离开应用程序边界时的实际数据为了最简单的方法,我应该将其序列化为一个并在另一个中进行反序列化。



这两种技术都有无数的例子,你必须自己做一些工作:)但这里是两种使数据可序列化的方法的例子

使用C#和.NET进行二进制序列化«John Nelson的博客 [ ^ ]

如何:序列化和反序列化JSON数据 [ ^ ]
Move your data classes into external dll, then refer that both places i.e. class Acme sits in your namespace myspace.one and you want it in myspace.two, then move it to myspace.types and refer that both places in myspace.one and myspace.two and they can be aware and handle same types.

Actual data when leaving application boundries for instance should be serialized in one and deserialized in the other for the most easy approach.

There are countless of examples of both techniques, and you will have to do some work yourself :) but here is example of two ways of making data serializable
Binary Serialization with C# and .NET « John Nelson's Blog[^]
How to: Serialize and Deserialize JSON Data[^]


这篇关于将数据从一个控制器传递到另一个控制器,这是另一个域MVC C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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