By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,758 Members | 1,223 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,758 IT Pros & Developers. It's quick & easy.

Serial Communications in ASP.NET

P: n/a

Hi All,

I've written an ASP.NET application (webservice) that does simple serial
communications via the .NET 2.0 SerialComm object.

The application runs fine on my development machine. The problem is when we
try to deploy it to another machine we receive: ACCESS IS DENIED TO COM1 PORT.

We have tried unsuccessfully to get this to work. We have tried the following:
1) Assign the IUSR.... account to Administrators
2) We have actually had the local administrator account run the webservice
3) rebooted
4) stopped and restarted IIS - etc. etc.

We are unable to resolve this. Is there a special permission that the
account needs? Once again we are running XP Pro and it works fine in
development but we can't get it to run on this other machine!!!!

Also - we have implemented the same code using a regular client application
and it works fine (i.e. copied all the code out and put it in a simple
windows form and we're fine).

The problem is running it as a webservice. It does not work!

Any thoughts - comments are appreciated! Thanks!

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.
May 31 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Your app is running as ASPNET not IUSR_ if I remember correctly. You can
change the user that the application pool that the application runs in. I
would however re-think your architecture as a webserver has no business
being connected to a serial port. I might make a remoting service that
handles the serial port then make a webservice front end.

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
"Franklin M. Gauer III" <Fr***************@discussions.microsoft.com> wrote
in message news:F4**********************************@microsof t.com...

Hi All,

I've written an ASP.NET application (webservice) that does simple serial
communications via the .NET 2.0 SerialComm object.

The application runs fine on my development machine. The problem is when
we
try to deploy it to another machine we receive: ACCESS IS DENIED TO COM1
PORT.

We have tried unsuccessfully to get this to work. We have tried the
following:
1) Assign the IUSR.... account to Administrators
2) We have actually had the local administrator account run the
webservice
3) rebooted
4) stopped and restarted IIS - etc. etc.

We are unable to resolve this. Is there a special permission that the
account needs? Once again we are running XP Pro and it works fine in
development but we can't get it to run on this other machine!!!!

Also - we have implemented the same code using a regular client
application
and it works fine (i.e. copied all the code out and put it in a simple
windows form and we're fine).

The problem is running it as a webservice. It does not work!

Any thoughts - comments are appreciated! Thanks!

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.

May 31 '06 #2

P: n/a

Greg - what do you mean by "...I would however re-think your architecture
as a webserver has no business being connected to a serial port..."? I have
no idea of what you are talking about. If you call up VS 2005 - WebForms -
the SerialPort component is there waiting to be used. Why not use it? Also -
I have found many code examples illustrating exactly what I am successfully
doing already. And they're using ASP.NET. I don't understand this and I feel
embarassed...

I am just having troubles with the communications part of this.

--
Franklin M. Gauer III

"Greg Young" wrote:
Your app is running as ASPNET not IUSR_ if I remember correctly. You can
change the user that the application pool that the application runs in. I
would however re-think your architecture as a webserver has no business
being connected to a serial port. I might make a remoting service that
handles the serial port then make a webservice front end.

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
"Franklin M. Gauer III" <Fr***************@discussions.microsoft.com> wrote
in message news:F4**********************************@microsof t.com...

Hi All,

I've written an ASP.NET application (webservice) that does simple serial
communications via the .NET 2.0 SerialComm object.

The application runs fine on my development machine. The problem is when
we
try to deploy it to another machine we receive: ACCESS IS DENIED TO COM1
PORT.

We have tried unsuccessfully to get this to work. We have tried the
following:
1) Assign the IUSR.... account to Administrators
2) We have actually had the local administrator account run the
webservice
3) rebooted
4) stopped and restarted IIS - etc. etc.

We are unable to resolve this. Is there a special permission that the
account needs? Once again we are running XP Pro and it works fine in
development but we can't get it to run on this other machine!!!!

Also - we have implemented the same code using a regular client
application
and it works fine (i.e. copied all the code out and put it in a simple
windows form and we're fine).

The problem is running it as a webservice. It does not work!

Any thoughts - comments are appreciated! Thanks!

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.


May 31 '06 #3

P: n/a

I'm sorry - I'm having troubles with the permissions part...

--
Franklin M. Gauer III

"Franklin M. Gauer III" wrote:

Greg - what do you mean by "...I would however re-think your architecture
as a webserver has no business being connected to a serial port..."? I have
no idea of what you are talking about. If you call up VS 2005 - WebForms -
the SerialPort component is there waiting to be used. Why not use it? Also -
I have found many code examples illustrating exactly what I am successfully
doing already. And they're using ASP.NET. I don't understand this and I feel
embarassed...

I am just having troubles with the communications part of this.

--
Franklin M. Gauer III

"Greg Young" wrote:
Your app is running as ASPNET not IUSR_ if I remember correctly. You can
change the user that the application pool that the application runs in. I
would however re-think your architecture as a webserver has no business
being connected to a serial port. I might make a remoting service that
handles the serial port then make a webservice front end.

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
"Franklin M. Gauer III" <Fr***************@discussions.microsoft.com> wrote
in message news:F4**********************************@microsof t.com...

Hi All,

I've written an ASP.NET application (webservice) that does simple serial
communications via the .NET 2.0 SerialComm object.

The application runs fine on my development machine. The problem is when
we
try to deploy it to another machine we receive: ACCESS IS DENIED TO COM1
PORT.

We have tried unsuccessfully to get this to work. We have tried the
following:
1) Assign the IUSR.... account to Administrators
2) We have actually had the local administrator account run the
webservice
3) rebooted
4) stopped and restarted IIS - etc. etc.

We are unable to resolve this. Is there a special permission that the
account needs? Once again we are running XP Pro and it works fine in
development but we can't get it to run on this other machine!!!!

Also - we have implemented the same code using a regular client
application
and it works fine (i.e. copied all the code out and put it in a simple
windows form and we're fine).

The problem is running it as a webservice. It does not work!

Any thoughts - comments are appreciated! Thanks!

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.


May 31 '06 #4

P: n/a
Which part on the permissions?

As for my architecture comment.

The SerialPort would be owned by a single ASP.NET worker process
http://www.codeproject.com/aspnet/aspwp.asp (it would in fact belong to a
single app domain).. you could therefor only ever have a single ASP.NET
worker process... You could not scale yourself to support multiple worker
processes (let alone multiple web servers). You could not for instance run
with an application pool setup to use 10 worker processes (1 would work and
then 9 would fail to open the serial port).

As a rule of thumb, it is best to keep resources like this out of your web
processes as you can then scale the web processes.

http://www.microsoft.com/downloads/t...yLang=en&oRef=
is a useful document .. see "Resource Affinity" in chapter 6.

A perfect example of where this could kill your performance would be the
case where you are polling for a set of data that could be accessed throguh
your webservice via some data methods and exposed a few methods that caused
data to be executed accross the port. By moving the serial port out of the
web process you could feasably have 50 webservers using the same serial port
(in a case where they were mostly having people ask for data methods that
would simply hit their local cache this would in fact be a great
architecture).

The other problem I see alot of with this type of setup is that the ASP.NET
worker processes prefer to restart themselves occasionally. By placing the
serial port code in the web app you miss any polling etc over that port that
would need to be done during this period of time.

The last problem I see, you have already run into. Your code must run in at
an elevated privilege level which opens up far more sruface area for
possible attacks on your system (as opposed to a small component running
with elevated privs your entire app must now run with elevated privs or you
must take other measures within your application to only run certain areas
with elevated permissions). Doing something like making the ASPNET_WP
account an administrator on your system is certainly bad.

Have you tried to get the current identity to see who you are running as?

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
"Franklin M. Gauer III" <Fr***************@discussions.microsoft.com> wrote
in message news:C8**********************************@microsof t.com...

I'm sorry - I'm having troubles with the permissions part...

--
Franklin M. Gauer III

"Franklin M. Gauer III" wrote:

Greg - what do you mean by "...I would however re-think your
architecture
as a webserver has no business being connected to a serial port..."? I
have
no idea of what you are talking about. If you call up VS 2005 -
WebForms -
the SerialPort component is there waiting to be used. Why not use it?
Also -
I have found many code examples illustrating exactly what I am
successfully
doing already. And they're using ASP.NET. I don't understand this and I
feel
embarassed...

I am just having troubles with the communications part of this.

--
Franklin M. Gauer III

"Greg Young" wrote:
> Your app is running as ASPNET not IUSR_ if I remember correctly. You
> can
> change the user that the application pool that the application runs in.
> I
> would however re-think your architecture as a webserver has no business
> being connected to a serial port. I might make a remoting service that
> handles the serial port then make a webservice front end.
>
> Cheers,
>
> Greg Young
> MVP - C#
> http://geekswithblogs.net/gyoung
> "Franklin M. Gauer III" <Fr***************@discussions.microsoft.com>
> wrote
> in message news:F4**********************************@microsof t.com...
> >
> > Hi All,
> >
> > I've written an ASP.NET application (webservice) that does simple
> > serial
> > communications via the .NET 2.0 SerialComm object.
> >
> > The application runs fine on my development machine. The problem is
> > when
> > we
> > try to deploy it to another machine we receive: ACCESS IS DENIED TO
> > COM1
> > PORT.
> >
> > We have tried unsuccessfully to get this to work. We have tried the
> > following:
> > 1) Assign the IUSR.... account to Administrators
> > 2) We have actually had the local administrator account run the
> > webservice
> > 3) rebooted
> > 4) stopped and restarted IIS - etc. etc.
> >
> > We are unable to resolve this. Is there a special permission that the
> > account needs? Once again we are running XP Pro and it works fine in
> > development but we can't get it to run on this other machine!!!!
> >
> > Also - we have implemented the same code using a regular client
> > application
> > and it works fine (i.e. copied all the code out and put it in a
> > simple
> > windows form and we're fine).
> >
> > The problem is running it as a webservice. It does not work!
> >
> > Any thoughts - comments are appreciated! Thanks!
> >
> > --
> > Franklin M. Gauer III
> > Applications Development Manager
> > Integrated Companies, Inc.
>
>
>

May 31 '06 #5

P: n/a

Thanks Greg for your clarifications. This has helped me out tremendously. I
appreciate it.

--
Franklin M. Gauer III
Applications Development Manager
Integrated Companies, Inc.
"Greg Young" wrote:
Which part on the permissions?

As for my architecture comment.

The SerialPort would be owned by a single ASP.NET worker process
http://www.codeproject.com/aspnet/aspwp.asp (it would in fact belong to a
single app domain).. you could therefor only ever have a single ASP.NET
worker process... You could not scale yourself to support multiple worker
processes (let alone multiple web servers). You could not for instance run
with an application pool setup to use 10 worker processes (1 would work and
then 9 would fail to open the serial port).

As a rule of thumb, it is best to keep resources like this out of your web
processes as you can then scale the web processes.

http://www.microsoft.com/downloads/t...yLang=en&oRef=
is a useful document .. see "Resource Affinity" in chapter 6.

A perfect example of where this could kill your performance would be the
case where you are polling for a set of data that could be accessed throguh
your webservice via some data methods and exposed a few methods that caused
data to be executed accross the port. By moving the serial port out of the
web process you could feasably have 50 webservers using the same serial port
(in a case where they were mostly having people ask for data methods that
would simply hit their local cache this would in fact be a great
architecture).

The other problem I see alot of with this type of setup is that the ASP.NET
worker processes prefer to restart themselves occasionally. By placing the
serial port code in the web app you miss any polling etc over that port that
would need to be done during this period of time.

The last problem I see, you have already run into. Your code must run in at
an elevated privilege level which opens up far more sruface area for
possible attacks on your system (as opposed to a small component running
with elevated privs your entire app must now run with elevated privs or you
must take other measures within your application to only run certain areas
with elevated permissions). Doing something like making the ASPNET_WP
account an administrator on your system is certainly bad.

Have you tried to get the current identity to see who you are running as?

Cheers,

Greg Young
MVP - C#
http://geekswithblogs.net/gyoung
"Franklin M. Gauer III" <Fr***************@discussions.microsoft.com> wrote
in message news:C8**********************************@microsof t.com...

I'm sorry - I'm having troubles with the permissions part...

--
Franklin M. Gauer III

"Franklin M. Gauer III" wrote:

Greg - what do you mean by "...I would however re-think your
architecture
as a webserver has no business being connected to a serial port..."? I
have
no idea of what you are talking about. If you call up VS 2005 -
WebForms -
the SerialPort component is there waiting to be used. Why not use it?
Also -
I have found many code examples illustrating exactly what I am
successfully
doing already. And they're using ASP.NET. I don't understand this and I
feel
embarassed...

I am just having troubles with the communications part of this.

--
Franklin M. Gauer III

"Greg Young" wrote:

> Your app is running as ASPNET not IUSR_ if I remember correctly. You
> can
> change the user that the application pool that the application runs in.
> I
> would however re-think your architecture as a webserver has no business
> being connected to a serial port. I might make a remoting service that
> handles the serial port then make a webservice front end.
>
> Cheers,
>
> Greg Young
> MVP - C#
> http://geekswithblogs.net/gyoung
> "Franklin M. Gauer III" <Fr***************@discussions.microsoft.com>
> wrote
> in message news:F4**********************************@microsof t.com...
> >
> > Hi All,
> >
> > I've written an ASP.NET application (webservice) that does simple
> > serial
> > communications via the .NET 2.0 SerialComm object.
> >
> > The application runs fine on my development machine. The problem is
> > when
> > we
> > try to deploy it to another machine we receive: ACCESS IS DENIED TO
> > COM1
> > PORT.
> >
> > We have tried unsuccessfully to get this to work. We have tried the
> > following:
> > 1) Assign the IUSR.... account to Administrators
> > 2) We have actually had the local administrator account run the
> > webservice
> > 3) rebooted
> > 4) stopped and restarted IIS - etc. etc.
> >
> > We are unable to resolve this. Is there a special permission that the
> > account needs? Once again we are running XP Pro and it works fine in
> > development but we can't get it to run on this other machine!!!!
> >
> > Also - we have implemented the same code using a regular client
> > application
> > and it works fine (i.e. copied all the code out and put it in a
> > simple
> > windows form and we're fine).
> >
> > The problem is running it as a webservice. It does not work!
> >
> > Any thoughts - comments are appreciated! Thanks!
> >
> > --
> > Franklin M. Gauer III
> > Applications Development Manager
> > Integrated Companies, Inc.
>
>
>


Jun 1 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.