Pages: [1]   Go Down
Author Topic: Access to the port 'COM4' is denied  (Read 2563 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am using arduino, and I made an ASP.net page to communicate with it. I connected arduino to serial-port COM4. When I run the ASP.net website, I get the following error:

Exception Details: System.UnauthorizedAccessException: Access to the port 'COM4' is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

I truely have no idea how to fix this problem. PS: I first did a windows form application and it worked. So there is nothing else using the COM4.

Thanks in advance.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am using arduino, and I made an ASP.net page to communicate with it. I connected arduino to serial-port COM4. When I run the ASP.net website, I get the following error:

Exception Details: System.UnauthorizedAccessException: Access to the port 'COM4' is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

I truely have no idea how to fix this problem. PS: I first did a windows form application and it worked. So there is nothing else using the COM4.

Thanks in advance.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 610
Posts: 49048
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I truely have no idea how to fix this problem.
The directions are right there:
Quote
To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.
Did you follow them?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 610
Posts: 49048
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Crossposted. Reported to moderators.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

which file do they mean by "file in explorer" ? do they mean the file containing the asp.net? or the asp.net file itself?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

chill man !! it's not like i am spamming the website.. i just didn't know which category my question best goes. so take it easy
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 610
Posts: 49048
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
do they mean the file containing the asp.net? or the asp.net file itself?
The .exe file.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 610
Posts: 49048
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
chill man !! it's not like i am spamming the website.. i just didn't know which category my question best goes. so take it easy
Pick ONE. If you don't get responses, ask a moderator to move it.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok didn't know that.. new to the forums concept...
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i don't have a file with the extension .exe in my project
Logged

Offline Offline
Sr. Member
****
Karma: 9
Posts: 254
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What version of IIS are you uing. By default I imagine that IIS blocks acccess to the COM ports for security reasons, so you'll probably need to enable this yourself. You could also try changing the ASP user, by default ASP creates a user on your PC with limited rights that it uses, but you can change it so that it uses an administrator account, though this has obvious security issues.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

apparently my computer didn't support IIS so I downloaded iis 7.5 express.. after installing it, I couldn't find out how to use it. it doesn't even show in my control panel\administrative tools.
Logged

Offline Offline
Sr. Member
****
Karma: 9
Posts: 254
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

apparently my computer didn't support IIS so I downloaded iis 7.5 express.. after installing it, I couldn't find out how to use it. it doesn't even show in my control panel\administrative tools.
If you open up the start menu and type in "iis" it should find the "Internet Information Services (IIS) Manager", in there look for "Application Pools", and select "Default Application Pool", in the advanced settings for this set the Identity to "LocalSystem", this should make your web server act as though it is runnning as a local user on the computer (with all of their rights).
Logged

Offline Offline
Sr. Member
****
Karma: 9
Posts: 254
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmmm, ignore my last post for the moment, I'm running IIS 7 on my PC, and I've just done a very quick and dirty test using a virtual COM port I have installed on my PC, it seems to work first time for me without having to change permissions smiley-sad
I did notice though the first time I ran it I forgot to close the serial port at the end of my code, and this actually blocked any further conections, with the same access denied error. Try killing the iis process (I think it's called w3wp.exe) and checking that your code will always close the serial port after each transaction, and this will hopefully work!!!
So you will have something like:
Code:
            SerialPort port = new SerialPort("COM8", 9600, Parity.None, 8, StopBits.One);
            try
            {
                port.Open();
                port.WriteLine("Give me data!!!");
                string data = port.ReadLine();
                Response.Write(data);
            }
            finally
            {
                if(port.IsOpen)
                    port.Close();//<---this is the important bit!!!
            }
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 480
Posts: 18722
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Please don't cross post! Threads merged.
Logged


Pages: [1]   Go Up
Jump to: