Fax in an asp.net page

J

jcvoon

Hi:

The following code work on win form application

Dim faxServer As FAXCOMLib.FaxServer
Dim faxDoc As FAXCOMLib.FaxDoc

faxServer = New FAXCOMLib.FaxServerClass
faxServer.Connect(Environment.MachineName)

faxdoc = CType(faxServer.CreateDocument("c:\Doc\test.pdf"),
FAXCOMLib.FaxDoc)

faxDoc.RecipientName = "receiver"
faxDoc.FaxNumber = "12345"
faxDoc.DisplayName = "test"
faxDoc.Send()
faxServer.Disconnect()


when i port the code to web form

Dim faxServer As FAXCOMLib.FaxServer
Dim faxDoc As FAXCOMLib.FaxDoc

faxServer = New FAXCOMLib.FaxServerClass
faxServer.Connect(Environment.MachineName)

faxdoc = CType(faxServer.CreateDocument(Server.MapPath("") &
"\Doc\test.pdf"), FAXCOMLib.FaxDoc)

faxDoc.RecipientName = "receiver"
faxDoc.FaxNumber = "12345"
faxDoc.DisplayName = "test"
faxDoc.Send()
faxServer.Disconnect()

It raise an exception "Access is denied. at
FAXCOMLib.FaxServerClass.Connect(String ServerName) at..."

If it is because of the IUSR account has no permission, then how do i
grant the permission to IUSR account so that it can access the Fax ? (I
don't know which resource to grant)

Another problem is (this happen in win form, but don't know it happen
in web form or not) when i try to fax the .pdf file it will launch the
adobe reader, how to avoid this ? at least the pdf viewer can close
automatically like when we fax the .txt document.

Please help (i need the solution urgently)
Thanks
JCVoon
 
G

Grant Merwitz

Your windows form is running under the current user, where as your web
application runs under the user selected in IIS.
By default this will be IUSR_<machine_name>

So you can either try use impersonation (this is set in the .config file,
either at the root or in the subfolder that contains this page):
http://msdn.microsoft.com/library/d...-us/cpguide/html/cpconASPNETImpersonation.asp

Or you can configure IIS to use an account that the fax machine allows
access to
in the default web site properties, click "Directory Security", then
click "Edit".
Change the Anonymous access use to be a user on your domain with access
to the fax machine

HTH
 
G

George

1. Use dcomcnfg.exe, find FAXCOMLib.FaxServer there and grant permissions to run/access to IUSR_ account.
2. The way how pdf is converted to tiff for faxing. The driver launches the application associated with that extension and command Print (or PrintTo) the application prints on the special FaxPrinter driver which has been installed with a fax system. The driver saves the output as a tiff for faxing.

So to launch another application you need to simply map that extension to it. You can use regular Windows Explorer, menu - Tools/Folder Options, tab - File Types. Hit Advance once found an extension to map verb Print or PrintTo.

George



Hi:

The following code work on win form application

Dim faxServer As FAXCOMLib.FaxServer
Dim faxDoc As FAXCOMLib.FaxDoc

faxServer = New FAXCOMLib.FaxServerClass
faxServer.Connect(Environment.MachineName)

faxdoc = CType(faxServer.CreateDocument("c:\Doc\test.pdf"),
FAXCOMLib.FaxDoc)

faxDoc.RecipientName = "receiver"
faxDoc.FaxNumber = "12345"
faxDoc.DisplayName = "test"
faxDoc.Send()
faxServer.Disconnect()


when i port the code to web form

Dim faxServer As FAXCOMLib.FaxServer
Dim faxDoc As FAXCOMLib.FaxDoc

faxServer = New FAXCOMLib.FaxServerClass
faxServer.Connect(Environment.MachineName)

faxdoc = CType(faxServer.CreateDocument(Server.MapPath("") &
"\Doc\test.pdf"), FAXCOMLib.FaxDoc)

faxDoc.RecipientName = "receiver"
faxDoc.FaxNumber = "12345"
faxDoc.DisplayName = "test"
faxDoc.Send()
faxServer.Disconnect()

It raise an exception "Access is denied. at
FAXCOMLib.FaxServerClass.Connect(String ServerName) at..."

If it is because of the IUSR account has no permission, then how do i
grant the permission to IUSR account so that it can access the Fax ? (I
don't know which resource to grant)

Another problem is (this happen in win form, but don't know it happen
in web form or not) when i try to fax the .pdf file it will launch the
adobe reader, how to avoid this ? at least the pdf viewer can close
automatically like when we fax the .txt document.

Please help (i need the solution urgently)
Thanks
JCVoon
 
J

jcvoon

Grant Merwitz :

I've try to add the IUSR_<machine_name> to users and administrator
group and restart my pc, but it still raise the access denied
exception, any idea ?

the impersonation, look complecated for me, i didn't try it.

Thanks
JCVoon
 
J

jcvoon

George:

I can't find the FAXCOMLib.FaxServer in the dcomcnfg.exe, I'm using
WinXP Pro, both IIS and Fax service is install on local machine, do i
need to register the fxscom.dll ?

I've follow your instruction, add a print action to the file type
(using Windows Explorer, > menu - Tools/Folder Options, tab - File
Types. Hit Advance), it still launch the acrobat reader (using my
winform application), is there a command line argument to tell the
acrobat reader run in invisible mode ?

Thanks
JCVoon
 
G

Grant Merwitz

i think the problem is that the fax is another machine, and your
IUSR_<machine_name> is a local user that does not exist on your fax machine,
nor can it exist.
Or more importantly, it is not a domain account, and cannot gain access to
your fac machine.

by the way, you did substitute <machine_name> for the real name of your
machine.
like mine would be "IUSR_GrantsPC"
But anyway, i think impersonation is a viable option, and is really not that
complicated.

Its as simple as one line in your configuration file.
<configuration>
<system.web>
<identity impersonate="true" userName="domain\username"
password="password"/>
</system.web>
</configuration>

Add this line into you main web.config, and substitute the userName and
password for your username and password.
Make sure your account has access to the fax machine. i.e. If your logged
onto this computer, you can send a document to the fax machine

HTH
 
G

George

1. Check event log. It will have an error with a GUID of object needs to be given access to. You can look up in registry the human readable APPID for dcomcnfg.exe

2. You can not hide the Acrobat window. But i think it will be invisible when you run it from ASP.NEt account. You see it only because you are running it under your account. The ASP.NEt account can not output anything on monitor. So do not worry here.

George.
George:

I can't find the FAXCOMLib.FaxServer in the dcomcnfg.exe, I'm using
WinXP Pro, both IIS and Fax service is install on local machine, do i
need to register the fxscom.dll ?

I've follow your instruction, add a print action to the file type
(using Windows Explorer, > menu - Tools/Folder Options, tab - File
Types. Hit Advance), it still launch the acrobat reader (using my
winform application), is there a command line argument to tell the
acrobat reader run in invisible mode ?

Thanks
JCVoon
 
J

jcvoon

Grant Merwitz :

Thank for the help.

Both the IIS and the Fax service is on the same WinXP Pro box.

My logon account is under adminstrator group, my Winform application is
able to print to the fax printer, but the Asp.Net application cannot.

I've try your suggession to add the <identity impersonate="true"
userName="VOON\jcvoon" password="mypassword"/> into the web config
file, and add
Response.Write(System.Security.Principal.WindowsIdentity.GetCurrent().Name())
at the Page_Load event and i'm able to see the aps.net is currently
running under my account, but when i try to fax, it still prompt me
access denied !

End up i grant a permission to ASP.Net Machine Account (under priter
and fax, Fax properties | Fax security) so that it can manage fax
configuration, then my asp.net application can fax without a problem,
regardless whether there is a <identity impersonate="true"> entry
exists in the web.config file.

But i still don't understand why the impersonate, and the ASP.Net
account under administrator group not work.

Now remain another problem, when i fax the pdf file it will create the
AcroRd32.exe in the process, it cause my asp.net application hang after
a few AcroRd32.exe created in the process, do you have this problem ?
is it possible to kill the process manually after the fax has been send
out ?

Thanks
JCVoon
 
J

jcvoon

George:

Thanks for the help.

1. Grant a permission to ASP.Net machine account so that it can access
the fax printer solved my problem. I've check three of the event log
but i can't find a log that is related to access denied.

2. The Acrobat window is not visible when fax on the asp.net
application, but it did create a AcroRd32.exe process for each document
that i fax, after a few fax, the Acrord32.exe raise an exception "..The
memory could not be read...", my application hang. Do you know how to
solve this problem ? I plan to kill the process manually after the fax
has been fax, but i don't know how to identify which process to kill,
any idea ?

Thanks
JCVoon
 
J

jcvoon

Hi Grant Merwitz, George:

I've add the following code after faxServer.Disconnect()

Dim myProcesses() As Process
Dim myProcess As Process

' How to retrieve the program associat with pdf, when i only know the
file extenstion ?
myProcesses = Process.GetProcessesByName("AcroRd32")
For Each myProcess In myProcesses
Try
If Date.Now.Ticks - myProcess.StartTime.Ticks >
TimeSpan.FromSeconds(30).Ticks Then
myProcess.Kill()
End If
Catch ex As Exception
' Probably access denied
End Try
Next

But i'm not sure whether it is safe or not. If another session has
create another AcroRd32 process, can the process be kill by this
session ?

Thanks
JCVoon
 

MsM

Joined
Nov 15, 2008
Messages
2
Reaction score
0
you can use this command:
aspnet_regiis -ga MachineName\AccountName

and give the folder all permission.

i faced this problem before but still i have problem; when try it with txt file its working smoothly but if i use it with doc file i have this error: The wait operation timed out.
 

MsM

Joined
Nov 15, 2008
Messages
2
Reaction score
0
Dear All,

when i try to send fax using gFAXCOMLib its working smoothly with txt file but if i try it with doc file i have this error : The wait operation timed out.

Is there anybody Can help me with this error??
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top