ASP.NET MVC - French/Spanish accent not correctly displayed - asp.net

I'm working on multilingual website where I want to get language resource from SQL db table. Resource Table column is already set to nvarchar though It's completely strange behavior get junk character when it's getting rendered in MVC View.
û rendered as û
However, It's working fine in my local machine but problem occurs on production environment only. Don't know why!!!
Static & Resource file content of different languages are rendered perfectly fine but the problem occurs only for resources retrieved from SQL table.
Tried setting meta tag with utf-8 charset in page & globalization with request response encoding to utf-8 in web.config but couldn't resolve my problem.
Should it be problem of IIS or Entity Framework is converting it to junk characters? Really confused.....
I'm using MVC4 with Entity Framework.
Any help will be greatly appreciated.

Related

How could IIS seemingly pull a web page out of thin air on my ASP.net WebForms application?

I am contracted to support a legacy ASP.net WebForms application. It's a commercial web site, and it's quite old.
Yesterday, I received a trouble-ticket that seemed to defy everything I know about web applications.
The trouble-ticket indicated that a certain URL sometimes returned an HTTP 404 error. The submitter also swears that the problem only occurs when browsing the site with Chrome. The web application is available in English and French, but the trouble-ticket says that the problem only occurs on the French version of the web application.
The URL looks like this:
http://www.example.com/promotion/mg_547/SpecialOffer.search
I tried navigating to the page in my development environment: http://www.example.dev/promotion/mg_547/SpecialOffer.search. It seemed to work fine.
Although these URLs are fictionalized, "mg_547" is an actual directory name in the URL.
I decided to navigate to the file in Windows Explorer to see if there is something unusual about the file. That's when things became surreal.
When I navigated to the "promotion" directory, I found that there is no "mg_547" directory (and besides, what meaning could such a name have?). My understanding is that in an ASP.net WebForms application, URLs corresponding to files on a physical disk, but here, there is not file; there is no directory!
I checked that there isn't an "mg_547" virtual directory in IIS.
I carefully checked that there isn't an MVC controller hiding somewhere in the application and I reviewed the global.asax.cs file to see if there could be some unusual routing set up. I couldn't find anything that would explain what I'm seeing.
I decided that the text of the page must appear in my code base somewhere, so I selected some text from the page (being sure that it didn't contain HTML-encodings) and searched for the text in the code-base; no matches!
Therefore, as far as I can tell, it seems as if the IIS server is just making up this page with Satanic Black Magic!
I believe that I've found the answer. #EdSF's comment was very helpful.
There is a .net class called PageHandlerFactory which is overidden in the web application. Specifically, this class overrides the PageHandlerFactory.GetHandler method. The mg_547 directory name is parsed in this overridden method and maps the URL to a different file on disk.
As for the original trouble-ticket that started all of this, perhaps there could be a bug in this method that causes the 404 error.
This is just as I expected. This is a corner of ASP.net I've not yet become familiar with.

Cannot Open InfoPath Form - DTD Prohibited

I have a browser-based InfoPath 2010 form. I'm getting an error opening the form in one environment. It works in at least three other environments. The error is:
The form template failed to load... Type: XmlException, Exception Message: For security reasons DTD is prohibited in this XML document. To enable DTD processing set the ProhibitDtd property on XmlReaderSettings to false and pass the settings into XmlReader.Create method.
I have seen this question posted around the Web, but the answers are vague and varied and are centered around products besides InfoPath. We also have other forms working in the environment where this form is failing, so it's something related to this particular form in this particular environment.
Problem solved. The error message was misleading, but turns out one of the data connections had a URL pointing to the wrong SharePoint farm. It was supposed to be pointing to the local form library. Cross platform calls tend not to work.
Basically make sure that the domain name in the connection file is matching the domain name where you're publishing your form.
For example, if your InfoPath form is located in:
https://extranet.MySiteName.com/The-Rest-Of-Your-Domain-Name
then make sure that all the domains (in this example extranet.MySiteName.com/)
in your data connection file match. The connection file line may look similar to this:
<udc:Query>
https://extranet.MySiteName.com/_vti_bin/My-WCF-Services/My-Data-ServiceName.svc/
</udc:Query>

Manually added WebResource.axd - Any security implications?

I added WebResource.axd (empty file) manually in production environment (IIS7 and Windows Server 2008) after chrome and firefox was giving error 404 for WebResource.axd. And now it is working fine, even with parameters. I am not sure why ASP.NET generating this script in final render result (no problem with VS2008), but now it is working. I want to know, is there any security implications other than what normally associated with WebResource.axd as it is in root directory?
Thanks
I also had this issue recently, after a code change WebResource.axd stopped working for my site. Basically, it exposes dynamic resources over http. For a longer explanation visit:
Just where is webresource.axd?
Typically, what happens is that one of the dynamic resources being requested has failed, but the resource name is encrypted. This blog post will help you decrypt the name, use it and the query string of your failing webresource.axd?___ request to figure out where the error is coming from.
Telerik webresource troubleshooting

Arabic resource files not being picked by ASP.NET web site

I'm working on a project that has a web application module that generates localized emails upon request. The app requires html templates localization for several languages. I decided to go with asp.net resource files since the email layout is not likely to change and the amount of keys needed was relatively small.
I'm using Global Resources and have around 15 different resource files for the required locales. I have my default resource file in English ("EmailTemplates.resx") and then several localized resource files ("EmailTemplates.ru-RU.resx", "EmailTemplates.zh-CN.resx", "EmailTemplates.it-IT.resx", "EmailTemplates.id-ID.resx", etc).
Among the resource files, I have two arabic ones: "EmailTemplates.ar-AE.resx" which is actually in English and "EmailTemplates.ar-SA.resx" which is in Arabic.
All the emails for non Arabic locales work perfectly. The app picks up the required locale and uses the corresponding resource files. But when I try to request the Arabic ones, it always fall back to the default resource file.
The way I'm setting up the culture is based on the data requested, and not the browser settings:
Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(culture);
While debugging I can see that the CultureInfo is properly set to "ar-SA" or "ar-AE" but when the app retrieves the corresponding resource value, it always picks up the default one.
I have entered Arabic data in the default resource file for testing purposes, and the Arabic text displays just fine, so I'm sure that it is not a font or HTML layout issue.
I have searched all around the Internet, proved different approaches, and no luck. The "ar-SA" and "ar-AE" are valid CultureInfo values and the app compiles without issues, but it seems that whenever I request the Arabic emails, the app can't find the Arabic resource files.
Any ideas? I'd really appreciate any hits and help !
Cheers!
Please use the language without the culture info
Eg. EmailTemplates.ar.resx
because the browser you are using might not have the Arabic in different cultures as i checked with my chrome .or try adding the language with that culture.example ar-AE ar-SA etc,But anyway it has the Arabic language without culture and it works.

MS Chart not showing on hosted site

I have a MS Chart component displaying fine on an ASP.Net page. When I deploy it I get a broken image. The settings in the web.config are the same and the temporary images folder has the correct permissions.
When I get the URL of the images I can see that the /.png file is not getting created.
What sort of things do I need to look at to track down the problem?
I was able to resolve the issue by ensuring that my application pool settings was using "ASP .net integrated" and not "ASP .Net Classic". This will ensure that your handler is being used.
I had the same problem when I was working with the charting in .NET 4 and my problem turned out to be related to the default value of the privateImages attribute and the fact that my code wasn't using any identifying attributes for the session or the user.
See my post here for an explanation of how I solved my problem.
It's also worth noting that the ASP.NET Development server ignores the config settings for charting and renders them in memory unless you specifically set an attribute to force it to use your config.

Resources