Go Down

Topic: Access to the port 'COM4' is denied (Read 3177 times) previous topic - next topic

zahidaoui

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.

zahidaoui

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.

PaulS

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?

PaulS

Crossposted. Reported to moderators.

zahidaoui

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

zahidaoui

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

PaulS

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

The .exe file.

PaulS

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.

zahidaoui

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

zahidaoui

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

tobyb121

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.

zahidaoui

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.

tobyb121


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).

tobyb121

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 :(
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: [Select]

            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!!!
            }

Nick Gammon

Please don't cross post! Threads merged.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Go Up