ASP.Net website not rendering correctly on client - c#

I have deployed a ASP.net website and for whatever reason the website is rendering like it should on the web server, but when i access it from a client some of the formatting is lost, so for instance the menu items disappear from the menu, i am at a loss as to where to begin as the website is functional, it just isn't rendering how it should, i suspect that it might have something to do with CSS, but really not sure.
I have tried to make remove some reference to bundles and called the style sheets directly using link with no difference.
I have checked i am able to access the site.css from a client too.
Having looked a bit further into it, IE is returning the following two errors:
SCRIPT5007: Unable to get property 'createElement' of undefined or
null reference jquery-3.3.1.min.js (2,6997)
SCRIPT5022: Bootstrap's JavaScript requires jQuery bootstrap.min.js
(6,31)

Have you checked the mime type registered on iis? It could be possible that the response for the css request could have a different mime type than what the browser expected and thus did not parse it/apply the style rules.
To check/fix this, open server manager -> browse to your site. In the IIS settings panel would be Mime types, ensure that text/css is the MIME Type for the .css extension, also in your link tag try including type="text/css" as well.

Thanks guys, managed to figure it out, the issue was there was a GPO setting that was ticked to display intranet sites in compatibility mode, i unchecked this and it began to work as expected, hope this helps someone else.

Related

DotNetNuke: Dnn cdn change for local intranet execution

We are running DNN 9.1.1 on a local network without internet.
A fontawesome CSS is loaded through CDN and we cannot find where is it defined.
Like showed in the below image the CDN is a not resolved host and fontawesome is not loaded:
I search in all my web folder, in the DB and DNN github sources but I don't find anything.
How can change the URL for loading locally fontawesome CSS?
Is it definided somewhere else?
Have you tried doing a text search for "font-awesome" inside all your skins folders: /Portals/_default/Skins/ ?
From your screenshot it looks like you're using Client Resource Management. Try disabling this, reload the site and right click > view page source on this page you posted. You should then be able to find the reference to font-awesome.
It appears to be added all the way at the bottom of the page below the </form> element. And then only when site is in Edit mode.
<!--CDF(Css|https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css?cdv=75)-->
A bit strange because all the core files are usually contained withing the DNN site itself. And it is the only file that is loaded from maxcdn.bootstrapcdn.com. The only other externally loaded file is an Open Sans font from fonts.gstatic.com

IIS configuration: Navigation to the webpage was canceled when converting page to PDF using SautinSoft.PdfVision

I am having a problem when trying to convert an ASP .Net page to PDF using SautinSoft.PdfVision.
Using this library is quite straight forward, all you need to do is tho provide the URL of the page you want to convert and the PDF destination path.
SautinSoft.PdfVision v = new SautinSoft.PdfVision();
v.ConvertHtmlFileToPDFFile(url, pdfFilePath);
Instead of having the page I ask for to be rendered as PDF, I always get the one saying "Navigation to the webpage was canceled", as if IIS (version 7.5.7600.16385) was redirecting systematically my request.
In my development environment (Visual Studio Express 2012 for web, version 11.0.50727.1 RTMREL), I do not have this problem at all. Visual studio uses its own local web server whose configuration is the one by default and it works like a charm.
I added some log in the Page_Load event of the page I want to convert and for sure in my prod environment, this event is never triggered since I don't get any logs meaning the page never gets loaded. In my dev environment, my log does confirm that the pages is being loaded.
I have read a lot about this "Navigation webpage canceled" problem but all the answers I could find were about client side configuration, trust level in IE. I am using Chrome and its settings are the same whether I am debugging or hitting the prod server.
So my intuition really tells me something is going wrong on the server side.
So does anyone of you know about some IIS configuration that could fix my problem?
Thanks for your help.
I also faced similar kind of issues when using sautinsoft PDFVision
Solution:
in iis select your websites---> go to ssl settings --> client certificate --> ignore
this works for me
other chances if above not work:
goto application pool --> advanced settings---> loaduserprofile=true

Asp.net ajax - losing session variables - Internet Explorer 8 and prior versions

I have been working on a legacy project (although C#) and trying to solve a session problem that have been encovered for years. It hapens on IE8 and prior versions. On IE9, Google Chrome, Firefox and Safari works fine.
In other words, we have a management software that works fine on all browsers. But there is a specific page that makes tons of Ajax requests, and in some point it loses the session data.
I have checked for cookie problems with Fiddle but they are always sent and the same.
These clues make us think that the problem is within the application. But if we remember the problem occurs just in IE8 and prior versions we think the issue is probably in the browsers.
We also use a legacy Ajax library. And the problem mustn't be there as many of our aplications
use it and they doesn't have the same problem.
We are using IIS7 with State Server
I'm almost out of ideas. I hope you have some.
I got it!
Using Fiddler, I saw a very suspect request for "/". There was something requesting for the site base URL. And I remembered that the default page of this particular web application kills the session data, in other words calling the login page also means to log the user off.
After some hours of debugging and sniffing I found what was making such request.
There is a javascript function that creates some image tags. Some times those tag were created with an empty address, in other words the src property of the img tag was a string with 0 legth.
It must be an IE8 and older versions bug, as they request the website root instead of not requesting anything. Maybe it's not a bug, but this behavior is certainly unexpected.
Phew! I still can't believe I found it.
Losing session state can be result of the application error. But if you claim that this happens only on IE8 and older versions, this could not be the case...
So I would suggest you to use page ViewState instead of session state. Let me know if did the trick for you?
Here is sample how to create propety based on page viewstate, just make sure you have enabled viewstate on page level:
public string MyProperty
{
get
{
return ViewState["MyProperty"] as string;
}
set
{
ViewState["MyProperty"] = value;
}
}

ASP.NET reCAPTCHA in Internet Explorer SSL Warning Message

I have implemented the reCAPTCHA solution (latest version), into my ASP.NET web project. It works fine and dandy in my local environment, but on our SSL encrypted server I receive the warning message "Do you want to view only the webpage content that was delivered securely? This webpage contains content that will not be delivered using a secure HTTPS connection, which could compromise the security of the entire webpage." This only occurs in Internet Explorer.
I've found, on these forums and others to change the deprecated server to the new of googles (old: https://api-secure.recaptcha.net to new: https://www.google.com/recaptcha/api), but I am not directly referencing the javascript files, just using the .net library.
Any help would be greatly appreciated!
If the MVC Helper is using Context.Request.IsSecureConnection as Dan has pointed out above, and your application server is behind a load balancer that intercepts HTTPS and forwards as HTTP, then OverrideSecureMode will likely be false and rendering would take place insecurely.
If behind a load balancer, one of the ways to find the originating protocol would be to do something like this (provided you have access to the X-Forwarded-Proto header field).
bool isSecureConnection = String.Equals(
filterContext.HttpContext.Request.Headers["X-Forwarded-Proto"],
"https",
StringComparison.OrdinalIgnoreCase);
From browsing the control's source, the control has a property called OverrideSecureMode that, when set to true, always causes the control to render via HTTPS.
The MVC Helper, on the other hand, doesn't seem to allow setting that property. It seems to be using Context.Request.IsSecureConnection to determine which hostname to use; discovering why that value is wrong for you is another way to attack the problem.

PDF binary data output in .NET

I have a question about outputting PDF files. Currently I'm storing the PDF in the database in binary form. I'm outputting the PDF file via a URL such as:
http://myhost.com/FileManager.aspx?FileId=8465b2f9-b64e-4a9a-a449-94b5adb3b278
so from what I could deduce, to the browser this is an .aspx page that is loading and not a PDF. Firefox and IE interpret this correctly and launch Adobe Acrobat, however since Chrome (12.0.742.112) has its own implementation of a PDF reader, it will open the file correctly, but then when someone goes to save the file in chrome, it wants to save it as a .aspx. If I simply rename the .aspx to .pdf, the file downloads correctly. However, I"m trying to avoid telling my customer that s/he may have to take that extra step.
When I chose to look at the headers that loaded in Chrome via Web Inspector, I see this:
FileManager.aspx:-1 Resource interpreted as Document but transferred
with MIME type application/pdf
I can completely understand why Chrome would say this.
Furthermore, I get a save as box upon page load when I add:
Response.AddHeader("content-disposition", "attachment;filename=blah.pdf");
However, I was hoping to just keep the file in a browser. So aside from using some URL Rewrite, is there a way I can manipulate the HTTP Headers to simply open the page as a PDF and save correctly in Chrome?
Lastly, I tried using a WebService, but I can't seem to write the binary data to the page.
this.Context.Response.BinaryWrite(bytes);
Any help is appreciated!
In the web application's top-level web.config, add the following <add> element to the <httpHandlers> section:
<httpHandlers>
<add verb="*" path="FileManager.pdf" type="ProjectName.FileManager" />
...where ProjectName.FileManager is the full name (namespace and classname) of the FileManager class in FileManager.aspx.cs.
This tells ASP.NET to handle the path /FileManager.pdf using the handler defined by ProjectName.FileManager. (System.Web.UI.Page implements the IHttpHandler interface, so every webform is a handler.)
Now you can serve the PDFs via a URL with a .pdf extension like so:
http://myhost.com/FileManager.pdf?FileId=8465b2f9-b64e-4a9a-a449-94b5adb3b278
You do not need to rename the physical FileManager.aspx file. When the user enters /FileManager.pdf?FileId=foo in the browser, ASP.NET will handle the request with the ProjectName.FileManager class defined in FileManager.aspx.
Note:
The above should work on Cassini (the Visual Studio "mini" webserver) with no further changes. However IIS by default only sends *.aspx, *.asmx, *.ashx requests to ASP.NET. Therefore, for the above to work on IIS, you need to tell it to send requests for /FileManager.pdf to ASP.NET. That is, you need to configure a "mapping".
With IIS 6 you need to configure the mapping using IIS manager.
With IIS 7 you can configure a mapping from your web.config--this makes deployment easier, but it depends on how your hosting is set up.
Something that worked for me was to add the intended filename between the application page name (in your case, FileManager.aspx) and the query mark (the ? mark).
So, in the end, you'd have something like this:
http://myhost.com/FileManager.aspx/myfile.pdf?FileId=8465b2f9-b64e-4a9a-a449-94b5adb3b278
Surprisingly, the correct application will run (Filemanager.aspx), the variables will be passed unharmed (FileId), the result will be treated as inline (if you didn't change it to attachment, that is) but the browser will think that the filename to use, in case the user wants to save the page, is myfile.pdf.

Categories