JavaScript 触发 - vb.net api 调用的反射?
您可以使用 javascript 代码的反射来调用 vb.net api 函数吗?
我刚刚开始玩反射,我有这段代码可以工作,我想将其更改为 JavaScript 页面。
Dim RawPlugin As Reflection.Assembly
RawPlugin = Reflection.Assembly.LoadFrom("C:\Inetpub\wwwroot\demo\MasterApplication\getSession\bin\Debug\getSession.dll")
Dim Instance As Object
Instance = RawPlugin.CreateInstance("getSession.class1", True, _
Reflection.BindingFlags.Default, Nothing, Nothing, Nothing, Nothing)
theValue = Instance.getSessionValue(Session).ToString
有谁知道这是否可能?
Can you call a vb.net api function using reflection from javascript code?
I just started playing around with reflection, I have this snippet of code that works, I want to change it to a javascript page.
Dim RawPlugin As Reflection.Assembly
RawPlugin = Reflection.Assembly.LoadFrom("C:\Inetpub\wwwroot\demo\MasterApplication\getSession\bin\Debug\getSession.dll")
Dim Instance As Object
Instance = RawPlugin.CreateInstance("getSession.class1", True, _
Reflection.BindingFlags.Default, Nothing, Nothing, Nothing, Nothing)
theValue = Instance.getSessionValue(Session).ToString
Does anyone know if this is possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
客户端代码不直接与服务器端代码对话。 如果您正在查找的信息在用户的页面请求之间不受影响,那么您有两个选择:通过页面请求将服务器端值输出到客户端(因此它的值位于页面上的 JavaScript 变量内),或者使其成为 ajax 调用。 如果信息在页面请求之间可能已过时,那么您唯一的选择就是从 ajax 调用返回该值。
Client side code doesn't speak directly to server side code. If the information you are looking for is unaffected in between page requests by the user, then you have two options: output the server side value to the client with the page request (so it's value is inside a JavaScript variable on the page), or make it an ajax call. If the information could possibly be stale in between page requests, then you're only option is to return the value from an ajax call.
在 ASP.Net 中,.Net 代码在您的 Web 服务器上运行。 JavaScript 在用户计算机的浏览器中运行。 该用户甚至可能没有 Windows,更不用说 .Net 运行时了。
就此而言,您的用户甚至可能没有启用 JavaScript。
In ASP.Net, the .Net code runs on your web server. Javascript runs on the user's computer, in their browser. That user might not even have Windows, let alone the .Net runtime.
For that matter, your user might not even have javascript enabled.
不,您不能直接从 javascript 使用反射或任何 .Net 相关内容。
NO, you can't use reflections, or anything .Net for that matter, directly from javascript.
soution:
您可以使用ajax创建回调,调用aspx页面,在页面加载时运行后面的代码,然后在.net中创建反射,然后将最终结果传递回javascript端,这是有效的,我知道这是这样......但这意味着在项目内部您需要有回调页面(如果有任何更改则需要编译)。
我想我需要做的是[使用JavaScript ajax调用执行反射的回调页面]
the soution:
you can create callbacks using ajax, to call a aspx page, that on page load, runs the code behind, that then creates the reflection in .net, and then passes the end result back to the javascript side, this works, i know this does... however this means that inside the project you need to have the callback page (needs to be compiled if there is any changes).
i guess what i need to do is [use JavaScript ajax to call a callback page that performs the reflection]