I developed a card reader application using ASP.net MVC5. The card reader used by is HID OMNIKEY 3121. When the card is inserted this application will read the name,gender,dob etc that is encoded in the chip. This is working fine in my local system and I am able to show it in a view. Then I publish the same to IIS in a server. Then I call the MVC website from my local(client) system. The card reader is connected to the local system but when click the read data it is giving a blank page.
Any configuration issue? Please guide me
Edited Controller
public class cardController : Controller
{
public ActionResult Index()
{
try
{
ReaderManagement readerMgr = new ReaderManagement();
readerMgr.EstablishContext();//extablishing card connection API
try
{
readerMgr.DiscoverReaders(); //discover card reader connected
}
catch(Exception ex)
{
return RedirectToAction("Nocard", "card");
}
PCSCReader[] readers = readerMgr.Readers;
PCSCReader selectedReader = readerMgr.SelectReaderByName(readers[0].ReaderName);
//Other select methods may be called...
selectedReader.IsConnected();
IDCardWrapper.LoadConfiguration();
bool IsCardConnected = selectedReader.IsConnected();
bool isContactless;
if (IsCardConnected) isContactless = selectedReader.IsContactless();
if (!IsCardConnected)
{
readerMgr.SelectReaderByName(readers[0].ReaderName);
try
{
selectedReader.Connect(readerMgr.Context);
}
catch(Exception ex)
{
return RedirectToAction("Nocard", "card");
}
}
CardInfo cardInfo = selectedReader.GetCardInfo();
try
{
PublicDataFacade publicDataFacade = selectedReader.GetPublicDataFacade();
CardHolderPublicData publicData = publicDataFacade.ReadPublicData(true, true, true, true, false);
ViewBag.sex = PublicDataUtils.GetSex(Utils.ByteArrayToUTF8String(publicData.Sex));
ViewBag.maritalstatus = PublicDataUtils.GetMaritalStatus(Utils.ByteArrayToHex(publicData.MaritalStatus, ""));
ViewBag.sponsortype = PublicDataUtils.GetSponsorType(Utils.ByteArrayToHex(publicData.SponsorType, ""));
ViewBag.dob = Utils.ByteArrayToStringDate(publicData.DateOfBirth);
ViewBag.fullname = PublicDataUtils.RemoveCommas(Utils.ByteArrayToUTF8String(publicData.FullName));
ViewBag.arabicname = PublicDataUtils.RemoveCommas(Utils.ByteArrayToUTF8String(publicData.ArabicFullName));
}
readerMgr.CloseContext();
}
catch (Exception ex) //(MiddlewareException ex)
{
}
return View();
}
View
Simply show the viewbag data assigned.