Printing from an application in IIS to a networked printer on server - ajax

I have a line of code that I can run locally as part of a service that works perfectly fine.
sReportPath = objCrystalUtils.ExportReportToPDF("Report Name", iReportInfoID)
This code is run as a part of a service, and when I unit test it by feeding it data, it ultimately builds the report and prints it.
When I run the exact same piece of code inside an .ashx from an ajax call. The reports are generated (I can see the pdf files being created on disk) but the printing is not happening.
oRpt.PrintToPrinter(objReport.DefaultAutoPrint, True, 0, 0)
In both scenarios the same code is used to print the report. (objReport.DefaultAutoPrint = 0 in both cases)
My only thought is that the location of the code that is calling this method is in a different spot relative to the location of the bills themselves.
The printer that I'm trying to print to is a network printer intalled on my machine, and I'm running Windows 7 IIS 6.1
Any thoughts?
Edit:
Here is a thought... if I'm running one as a unit test locally and im running the other through a web app that is running via IIS, is there a difference in user id and user access to the default printer?
Edit:
So I added my local ASP, IUSR and SYSTEM users to the printer security and allowed them to print... no dice. So I checked the EVERYONE user and it is set to access and NO users are denied... so I think that kinda kills that line of reasoning.
Edit:
I changed the name of this post since I no longer think that the issue is ajax related since If I try to do the same process in code bebehind from a post back instead of running it from an ajax call i still get the same problem.

Patrick, for me it is a known issue of crystal reports, printing a certain report from a running application via IIS.
I got the same issue before, and upon our search for that issue, we got the following;
Report to be generated, exported, and then to be downloaded to client machine,
so user can print it locally (say, report will be exported as PDf file,
user can use print option of PDF reader).

It's not Crystal Reports or other third party app's problem. It's usually the IIS_IUSER's permission problem because it has no access to any network printers. A possible solution is in Process.Start doesn't work in IIS

Related

Error 502 with Laravel when exporting to Excel on Azure Web App Linux

I have a Laravel App running on Azure Web App Linux service, all running nice and smoothly until I reach a feature that exports a query to an XLS for download. Then I receive the ERROR 502.
On my local environment works normally, I can export the query to XLS with no issues, it is not a large query, just a few rows.
In the same app, I have a function that exports to XLS just 1 row at a time and works fine, so it is just when I go for a larger(ish) query.
Any ideas? I have tried scaling up, restarting the app, apache, changed .ini (via .htaccess to increase execution time).
There is no trace in the logs either, there is something about the container crashing but cannot trace it to this particular error.
Ok, managed to solved it... was not straight forward at all. It has to do with the size of the query, even tough is not big by any means (a couple thousands max) raising memory limit to 1024M or further ended up in 502 Error. Decided to try different and moved from Laravel Excel to Fast-Excel which is less featured but man... it works. Now everything downloads perfectly. In case you are having this issue give fast-excel a try.

Batch script to block IP in windows firewall

I am creating a batch script to deal with the brute forcing through RDC on my server.
The way I plan on doing this is by making windows run my script when a failed RDC is logged in windows security log. I will add a whitelist to prevent trusted IP addresses from being blocked. It will also log how many times the IP has tried to login, and if it fails more than 5 times in a row, it will be blocked.
Problem is, I don't know how to pass the IP from the logged event to the batch script.
The Windows Server 2008 R2 event viewer has an ability to start a program when a specific event (With a event number) occurs. It has a box for arguments that can be passed onto the program that I can specify (which will be this batch script). However, It does not specify what arguments it can pass on (I want the IP to be passed onto the batch script... that is all).
Any help would be greatly appreciated.
I managed to fix it myself, using this. I adapted the one he had over to include $(IpAddress) and got it working after a bit of mucking around.

Could not obtain information about Windows NT group / user, error code 0x3a

I am trying to deploy a SQLCLR library to SQL Server 2008 R2. In visual studio I have set up the data connection and it works correctly (I can run queries), but when I try to deploy I get the message "Error: Could not obtain information about Windows NT group / user , error code 0x3a."
This is strange because I have set up the data connection to use SQL server authentication on a different user name.
I receive the same error when I run CREATE ASSEMBLY while logged in to the SQL management studio with the different user name.
To add to the mystery, when I deploy using permission set SAFE everything is fine. However my assembly requires EXTERNAL ACCESS.
What could be the problem with deploying my assembly?
This issue wasted so much time I feel compelled to share the solution so that nobody else falls into the same trap.
Issue was resolved by setting the SQL Server Active Directory Helper service to run on Manual, then rebooting the server.
This issue arose in a different environment for me:
Windows 10 box;
The user Windows complained about was an AZUREAD user;
On my Win10 box there was no SQL Server Active Directory
Helper service, so I couldn't try the original solution posted by
ose.
I was able to work round the issue by removing the AZUREAD user as a SQL Server user while I added the assembly.
In my case that user was not essential to have as a SQL Server user, but I dare say it would be possible to re-add the user back later should this be required.

MVC3 site deployed on IIS6 stops working after 20 minuttes with 404 Not Found

I'll try to make this short, feel free to ask for more details.
A mobile edition a a web-site has been created using MV3 razor and deployed to an IIS6 web-server using extenstionless URL's. Since .NET4 is installed on the server there is no special configuration done on the server to get extensionless urls work. When I try to access the site with the URL: http://site/m/ i get a 404 Not Found error.
What I do to produce this problem:
Right-click on project in VS2010 and publish to local file system.
ZIP all files in and transfer to production server + unzip there
Right click on production web-site and add a virtual directory for the new application
Create a new application pool with all default settings
Put the new virtual directory/application in that application pool
Try to access the URL in the browser; receive 404 Not Found
The thing that puzzles me, is that if I replace Step 1 with "File->Create New MVC3 Project" and then publish to local file system everything works fine:
The test-project is displayed in the browser with the name i used http://site/mvctest/
I do not need to use any extensions
It does not stop working after 20 minutes (see next paragraph)
And now for the (even) weirder part:
If I now move the "m" application into the application pool just created for the "mvctest" application; it works too. But only for 20 minutes (or whatever value I have set for "Shutdown worker process after being idle for").
Any ideas?
EDIT: If I add wildcard mapping to the /m/ virtual directory it works, but that should/could also affect performance in a bad way?
it sounds like your first scenario the handler isn't setup to handle the mvc requests. IIS 6 needs to be integrated or an extension for MVC mapped.
Set the app pool up to run in integrated pipeline mode. What happens then? This should work. Also check the event log for rapid fail protection kicking in because of worker process resets.

Problems with Database Deployment using VS2010 (Package/Publish SQL tab)

Background:
I am using the deployment tools in Visual Studio 2010.
I right clicked my project and selected Package/Publish settings. Put all my settings in there ...
I am then using "web deploy" to tranfer the files to my remote server running a remote agent service and this is working fine. The transforms i have on my Web.Release.config do their thing and the server can access the database I created manually.
Problem:
My next step was to get the Database Deployment working too.
I went into the Package / Publish SQL tab and entered my Connection string for the destination database.
(Data Source=MyDBServer;Initial Catalog=Database2;User ID=User;Password=pass)
This database is empty ready to accept the import.
I also enter in the connection string for the source database. This lives on the same server.
(Data Source=MyDBServer;Initial Catalog=Database;User ID=User;Password=pass)
Database Scripting options are set to Schema and Data (changing this makes no difference) and the database scripts are set to [Auto Generated Schema and Data]
When i deploy this now, i get the error:
Error 4 Web deployment task
failed.((09/06/2010 16:41:51) An error
occurred when the request was
processed on the remote computer.)
(09/06/2010 16:41:51) An error
occurred when the request was
processed on the remote computer. The
entry type 'Unknown' was not expected
at this time. The serialization stream
may be corrupted.
Additional Info:
I can successfully create a package with no problems. I looked at the contents in the zip and can see the SQL is generated fine (so no problems connecting to the database). I can then copy this SQL and run it as a new query on the new database and the tables and data are created fine.
I can not seem to work out where this is going wrong, i googled the error and there are no entries on the whole internet. Anyone have any ideas?
Addendum:
To get some further idea of what might be going on, i sent the package across to the server and imported it using IIS. It told me i needed SQL Server Management Objects. So I installed that.
Next attempt it told me my user did not have permission to create the database, I thought excellent this must be the problem. :Granted access - Re-run. Passed!
So i deleted all the tables and went back to VS2010 clicked publish and i get the same error. :(
Sorted it!
Thank goodness, i was totally out of ideas when i went back to a video by hanselman. He mentioned that the Web Deployment Agent can have permissions. I went in had a look and there was a tab in it's properties called log on.
I entered the detials of an account with a decent level of access and clicked okay.
I then restarted the service as requested to enable the changes.
I then went back to VS 2010 and clicked Publish Web.
Music to my eyes, i see the words "Publish succeeded", I check the database and the tables are there. Excellent!
I think i scared the office by getting a little over excited, if you get this problem and this solution fixes it for you, try to hold in the temptation to shout out "YES!, yes, get in!" while laughing maniacally or people will think you're weird like me.

Resources