Different Behaviour of pdfConverter (ephtmltopdf) on 2 Different production Servers - c#

I am using an ephtmltopdf dll to convert an .aspx page to a pdf.The pdf Converter successfully converted a published page on a production server which uses Windows 2008 server and IE 8 into a pdf.But when i published the same page on another production server which uses Windows 2003 server,it showed an error
Could not generate the PDF document. Could not render the url. Could
not get image from url.Navigation timeout..
I tried loading the page url which i am trying to convert to pdf in a web browser and surprisingly it loaded perfectly.First i thought may be some issue with my .aspx html code and i tested by publishing only the design of the .aspx page.And it was successfully converted.So i thought may be some issue with the c# code.So i checked my code log and surprisingly nothing seems wrong with the c# code.All c# code executed successfully.
After i bit of googling some suggested an increase in pdfconverter.Navigation timeout....so increased that too, but still getting the same error.

ephtmltopdf dll that i was using was some how corrupt i guess,since no matter what ever navigation timeout i was setting it was getting timed out after 1 min ...so i downloaded a new dll from their site .....and bingo it worked like a charm...

Related

Dynamic HTML in WPF WebBroswer - conent set by BrowserBehavior.Html, linking to file:/// url - does not behave

I am working on a system that has a WPF WebBrowser that is displaying dynamically generated HTML.
This contains links to files, using file:///servername/filename.ext addresses.
This should have worked in times gone by when this was first developed, but does not seem to behave now.
What I can see:
White click on the generated file in the browser of being an HTML file: File is served from about:blank and in the Internet Zone. Clicking a link does nothing.
What I have done:
I have added about:blank to the Trusted Zone, and have set the security for the Trusted Zone to Low. Clicking a link still does nothing.
Created an HTML file and hosted it on my local IIS. Browse to this file in IE. The file contains a link to a file:/// address. Nothing happens on click.
Added http://127.0.0.1 to the Trusted Zone. The above test still fails.
Changed the generated HTML to be a link to http://www.google.com. This works.
What I think is happening:
The WPF WebBrowser is IE underneath. Did IE have a security update that stopped access to file:/// paths?
What I cannot do due to technical restrictions with deployment:
Have the generated HTML and the files linked to served by a web server so everything is within an http(s) environment.
What I can do:
Update browser settings
Update our code
Update - additional information:
The HTML is being displayed on the WPF by binding to a string that contains the HTML (effectively <html><body>Look! Stuff!<br />Whatever</html>)
file:///foo/whatever.txt exists and I have access to it
That file is generated by a process on a server and the client is generating the link to the file. This is a historic design, I didn't come up with it, I'm just maintaining it. I can't do massive code overhauls.
I cannot install any additional services anywhere
All Browsers have updated to prevent interesting stuff happening on local HTML files. Because you could do interesting stuff in the past it meant interesting exploits could be utilized too.
I've had a recent issue where I created a HTML in code and wanted to display it in CEFSharp (much better than WebBrowser by the way) with a link to CSS and JavaScript Files.
How I fixed it was to run a LocalHost and did this using this code which works really well: An HTTP file server (130 lines of code) in VB.Net
For testing your HTML outside of code you could run this batch file to start your LocalHost:
ECHO OFF
ECHO "Launching Localhost:8080"
py -3 -m http.server
ECHO "Loading HTML.."
start chrome localhost:8000
This batch file assumes you have Python 3+ installed. You can verify this in the Command Prompt with:
python --version
I've solved this by cheating a little.
I've got the VM to write the HTML out to a file, and then pass the file name to the browser in the view. This means that I am displaying the created content from file:////foo.htm, and that is fine for links to file:///server/bar

Recovering URL don't return expected result

I'm working on .Net App in C# and I have problem,after I got latest version from Source Control my application can't start. After Debugging I found that these lines:
HttpApplication app = (HttpApplication)source;
var requestedResourceAbsoluteUrl = app.Request.Url.AbsolutePath.ToLower();
return not the Default.aspx page, but only Default(with missing .aspx in the end). I tried everything. Mapped again the solution. Tried in different browsers, repaired Visual Studio. I used Fiddler to detect the request. This is about every page in the application. Everything is OK with my coworkers project wich checkined this version
I'm posting the solution: I deleted all history, cookies, cache and other data in the browsers and now everything seems fine. It keeps not working in IE.

Response.Redirect no longer opening network file

I've got an ASP.NET site which allows users to view/open files from a shared network folder via links which call response.redirect passing in the full location of the relevant file (using a mapped drive value on appserver, not specific server name).
This works fine in IE7 but now w're doing a Win7 upgrade it isn't working in IE9 (or Chrome). For IE9 it displays basic "Internet Explorer cannot display the webpage" message.
I've tried changing it to pass in the path using server instead of mapped drive but that's worse, is tries to start at root of application directory and then acts as if server is a folder within it (and displays "The page cannot be found").
The site probably shoudln't have ever been designed in this way but I need a dirty workaround, no time for complete redesign. Any ideas? If the cause is how newer browsers handle the redirect response is it possible to alter an advanced setting to mimic previous version? I've tried adding site as trusted and also compatibility view.
Sample code:
Response.Redirect("R:\SharedFolder\indexedEmail.msg"); //Where R is mapped to netshare
Try using using the file:// URL prefix. The newer browsers may not be assuming that the URL is pointing to the local file system.

Site using code behind files from the wrong directory?

What settings in ASP.NET determine where (as in which directorie(s)) a website will look for its code-behind files?
I have two versions of an asp.net c# website, Live and Dev.
Live site: www.example.com with the pages and code in c:\dev\websites\examplecom_new
Dev site: d3.example.com with the pages and code in c:\dev\websites\examplecom-d2
There are historic reasons why the live site's directory ends in _new and why the dev site has d3 as its hostname and -d2 on its directory name, but they work and until now we've had no issues, developing things on d3 for subsequent release to live.
I recently refreshed the dev site to be an exact copy of the live one (I usually do this before starting a new round of work), and started on some development work. However, when I tried to run the code via the website, even though the browser was showing the Dev URL, d3.example.com, the error message referenced a code file from the live site's web directory, c:\dev\examplecom_new, not the development version c:\dev\examplecom-d2.
I've gone through the code in detail to ensure there are no hard-coded references to either the www site or the path to the live site directory, and as far as I can tell there are none. The code files in all cases are referred to in the .aspx files as local links, for example:
<%# Page Language="C#" MasterPageFile="~/ExampleCom.master" AutoEventWireup="true"
CodeFile="Checkout.aspx.cs" Inherits="Checkout" Title="Untitled Page" %>
Yeah, I know "Untitled Page" isn't the most useful title in the world. :)
I've gone through web.config, had a look in app_code\general.cs, and checked all the tabs on the Properties element in IIS, but I can't find anything that could be telling the site to use the .cs files from the live dir instead of the dev one.
I tried restoring the previous (pre-refresh) version of the Dev site (I always back them up before replacing, just in case), just in case there was a config change I wasn't aware of, but the old version exhibits exactly the same problem, the Checkout page calls code from live, not dev, even though its URL is showing the dev verson in the browser.
Needless to say this is something of a showstopper, the error that's happening appears to be due to a session mis-match between live and dev, but I have no idea why the dev site is calling code from the live site instead of code in its own directory. Any pointers to what might be wrong would be appreciated. I've tried both Googling for "asp.net code behind files called from wrong directory" and related searches, and searching Stack Overflow for the same types of thing, but not seen anything related. We're not using pre-compiled binaries, just standard .aspx pages and .aspx.cs C# code files.
At first I'd assumed there must have been a hardcoded redirect kicking things over from dev to live, however I can see no trace of one and the browser address bar still shows d3.example.com/Checkout.aspx when I'd have expected a redirect to live to change it to the www version.
The webserver is IIS 6 and we're running ASP 2.
Run "iisreset" command from command line and then clear temporary folder. All applications will be recompiled after that.

elegant maxrequest handler

Another question from me. This wont be an easy one!
I'm having issues with handling a simple upload.
Pre Requirements to test with:
- No Flash (hijacking)
- Basic upload field usage + form to post
- Max file size is 20MB (web.config maxrequestlength)
- I'm running the web site with the build in IIS development tool in visual studio (i think)
- I'm using a MVC web project
Question: Is it possible to show a nice error message to the user when a file is larger than 20MB? (Without getting the whole file to the server first)
These links helped me the most:
http://www.telerik.com/community/forums/aspnet/upload/maximum-request-length-exceeded.aspx
ASP.NET MVC: Handling upload exceeding maxRequestLength
http://forums.whirlpool.net.au/archive/809909
http://forums.asp.net/t/1106579.aspx/1
Catching "Maximum request length exceeded"
But still i haven't been able to fix the issue. Atm i use the code of the accepted answer of the last link (Catching "Maximum request length exceeded"), but my code crashes when i run the code line below:
this.Server.Transfer("~/error/UploadTooLarge.aspx");
Error message: Error executing child request for ~/error/UploadTooLarge.aspx.
I think i get this message because i'm using VS.NET's build in web server (see: http://forums.asp.net/t/1106579.aspx/1 last post of that page).
I'm affraid i made the whole question a bit hard to read. In short:
How can i show a neat error message when i uploaded file is too large (using S.NET's build in web server)?
If you don't want to send to whole file to the server first, then your only option would be javascript.
The FileReader object would solve that for you
https://developer.mozilla.org/en-US/docs/DOM/FileReader
Problem being it won't work on older browsers.
Now, if older browsers are not a problem for you then you should find plenty of tutorials showing you how to use the FileReader object. With it you can do asynchronous uploads so you even add a nice progress bar considering is fairly large file.

Categories

Resources