HTML 页面上的 .Net Active-X:无法获取 MAC 地址
我尝试从放置在 HTML 网页上的 active-x 获取 mac 地址
[PermissionSet(System.Security.Permissions.SecurityAction.Assert, Unrestricted = true)]
public string GetMacAddress()
{
var nic = NetworkInterface.GetAllNetworkInterfaces()
.FirstOrDefault(x => x.OperationalStatus == OperationalStatus.Up);
return nic == null ? null : nic.GetPhysicalAddress().ToString();
}
,但此代码失败并出现错误:
System.Net.NetworkInformation.NetworkInformationPermission, System, Version=2.0.0.0...
同时代码非常适合桌面应用程序。
我猜想 .net active-x 的使用存在一些限制。
我怎样才能避免这种情况?我可以通过其他方式从 active-x 获取唯一且稳定的工作站 ID 吗?
I try to get mac address from active-x that is placed onto HTML web page
[PermissionSet(System.Security.Permissions.SecurityAction.Assert, Unrestricted = true)]
public string GetMacAddress()
{
var nic = NetworkInterface.GetAllNetworkInterfaces()
.FirstOrDefault(x => x.OperationalStatus == OperationalStatus.Up);
return nic == null ? null : nic.GetPhysicalAddress().ToString();
}
But this code fails with error:
System.Net.NetworkInformation.NetworkInformationPermission, System, Version=2.0.0.0...
Meanwhile code works great for desktop applications.
I guess there are some limitations with .net active-x usage.
How can I avoid that? Can I get unique and stable workstation ID from active-x any other way ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在 silverlight 中发现了几个类似的问题:
在 Silverlight 中获取 MAC 地址
看起来由于 .网络安全设置,但我们执行以下操作:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\caspol.exe -machine
-quiet -addgroup Trusted_Zone -site acitve-x-host-site FullTrust -name
SecutityException -description "..."
最后我决定将 Active-X 重写为 C++\ATL 之一。
I have found several similar issues with silverlight:
Get MAC address in Silverlight
It looks there is no way to get mac address due to .net security settings except we do the following:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\caspol.exe -machine
-quiet -addgroup Trusted_Zone -site acitve-x-host-site FullTrust -name
SecutityException -description "..."
Finally I decided to rewrite Active-X to C++\ATL one.