1

I have found the following to my mvc controller. But how will I get the result in my cshtml? anyone have an idea?

  private string GetMacAddress()
        {
        string macAddresses = string.Empty;

        foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
            {
            if (nic.OperationalStatus == OperationalStatus.Up)
                {
                macAddresses += nic.GetPhysicalAddress().ToString();
                break;
                }
            }

        return macAddresses;
        }
Bram
  • 49
  • 2
  • 11
  • http://stackoverflow.com/questions/1641868/how-to-get-client-ip-address-using-jquery – Matt Bodily Jan 17 '14 at 17:09
  • Thanks for this Matt.. I use this solution: @Request.UserHostAddress to get the ip address.. i am looking for the unique (hardware) address – Bram Jan 17 '14 at 21:00
  • ah sorry about that, here is the link regarding the mac address http://stackoverflow.com/questions/3385/mac-addresses-in-javascript – Matt Bodily Jan 17 '14 at 21:35

1 Answers1

-1

Since it is a string you can send it with a ViewBag http://www.tutorialsteacher.com/mvc/viewbag-in-asp.net-mvc

in your conroller you can write something like this

ViewBag.macAdress = GetMacAddress();

and at the cshtml end you can write something like

<p>@ViewBag.macAdress<p>
molham556
  • 183
  • 1
  • 6