0

I following this article for sending SMS it is a winform application.. I have referenced all the Dll's to my asp.net application.....

I use an aspx page to detect a mobile device connected to a PC..... But it alwys shows COM 'n' Port could not be opened.....

using SMS;
using GsmComm.GsmCommunication;
using GsmComm.PduConverter;

public partial class _Default : System.Web.UI.Page 
{
    protected void Page_Load(object sender, EventArgs e)
    {
        GsmCommMain comm = new GsmCommMain(6, 9600, 300);
        comm.Open();
        if (!comm.IsConnected())
        {
            Response.Write("No Phone Connected");
        }
        else
        {
            SmsSubmitPdu pdu = new SmsSubmitPdu("test", "+919999999999", "");
            CommSetting.comm.SendMessage(pdu);
        }
    }
}

EDIT:

I use the web development server that ships with Visual Studio... If go to Control Panel -> Phones & Modems -> Modems i could see my mobile connected in com6...

i have tested the winform application it works fine...

Is this the answer?

ASP.NET pages are supposed to work. What is happening over here is that when you click on open_com button, the ASP.NET page posts back to itself, executes the event handler i.e., opens the port. Then when the page finishes processing the post back, it is unloaded. At this point the COM1 objects is also destroyed.

2
  • 2
    You do know that that code runs on the server, right? Commented May 10, 2010 at 7:14
  • @Henk ya i do know.. But its my local machine then it should detect my device.... I dont host my application on a server... It will be used by only one client machine... Commented May 10, 2010 at 7:17

2 Answers 2

2

Which webserver are you using? If its the web development server that ships with Visual Studio? Then it should be working. If you want to get it working with IIS you need to use impersonation or run the ASP.net worker process in a different security context with admin privileges.

Also try to test your sample in a console application first.

Sign up to request clarification or add additional context in comments.

Comments

0

It's most likely permissions.

Unless you are using impersonation the site will run as the ASPnet user which has very low privileges. Either set the site to impersonate an admin user, or set the site to run as a high priviledge user.

Alternatively, and my personal recommendation, rather use an online service like http://www.clickatell.com/ to send and receive SMSes. It's a heck of a lot easier, it's cheaper, and it's more robust.

1 Comment

how to change to admin user? Any suggestion?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.