TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rupesh Kahane
102
19.1k
4.2m
How to get mac address & Serial Number who is access URL MVC
May 13 2020 7:27 AM
I have an MVC application contains 1 controller & Index action method.
I have two different methods to get all MAC addresses & Serial Number of laptop / computer.
When I publish or host my code on XXX server & tries to access the Index method then it stores the information of all mac addresses & serial number
Who is accessing the that page.
But what happends my code is always runs in the IIS of server so it stores the all details about that servers only,
not about my clients MAC address & Serial Number.
Suggest me something I can track all clients / users / visitors mac address those who are accessing the page.
Below is my code
public
class
HomeController : Controller
{
public
ActionResult Index()
{
try
{
var allMacAddresses = getAllMacAddress();
var serialNo = getSerialNumber();
File.AppendAllText(
"myfilePath"
, allMacAddresses +
" "
+ serialNo + Environment.NewLine);
}
catch
(Exception)
{
throw
;
}
return
View();
}
public
static
string
getAllMacAddress()
{
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
String sMacAddress =
string
.Empty;
foreach
(NetworkInterface adapter
in
nics)
{
if
(adapter !=
null
)
{
IPInterfaceProperties properties = adapter.GetIPProperties();
if
(sMacAddress ==
string
.Empty)
{
sMacAddress = adapter.Name +
" : "
+ adapter.GetPhysicalAddress().ToString();
}
else
{
sMacAddress = sMacAddress +
" , "
+ adapter.Name +
" : "
+ adapter.GetPhysicalAddress().ToString();
}
}
}
return
sMacAddress;
}
public
static
string
getSerialNumber()
{
Process process =
new
Process();
ProcessStartInfo startInfo =
new
ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.FileName =
"CMD.exe"
;
startInfo.Arguments =
"/C wmic bios get serialnumber"
;
process.StartInfo = startInfo;
process.StartInfo.UseShellExecute =
false
;
process.StartInfo.RedirectStandardOutput =
true
;
process.Start();
process.WaitForExit();
string
output = process.StandardOutput.ReadToEnd();
return
output;
}
}
In above code to get serial number I am using command prompt i.e. cmd.exe so it always run on the server.
I would like to execute that command it on clients / users laptop who is accessing the page
Is their any other way so I can get the information? please suggest
Reply
Answers (
2
)
How to call the webmethod on button clickevent for firebase
DropDownList Binding and Bind value storing?